i'm building an 'edit-post' system...
here's what i have:
- Code: Select all
var wymArray = new Object();
// just update the form values accordingly to the selected post
var update_form = function(form) {
form.find('#op').val(op);
form.find('#title').val(post.find('.title').html());
form.find('#text').val(post.find('.text').html());
form.find('#id').val(pid);
};
if (!form.exists())
{ // fetch edit_post form
$.post(formgenerator, data, function(form_html)
{
form = $(form_html);
update_form(form);
form.find('textarea').wymeditor({ html: 'hi' });
wymArray['edit_post'] = WYMeditor.INSTANCES.last(); // store instance
post.replaceWith(form);
// everything is fine here; the original text ("hi") is shown
});
} else { // user tries to edit another post, and there is already a wym instance
update_form(form);
var html = post.find('.text').html();
var inst = wymArray['edit_post'];
inst.html(html);
post.replaceWith(form);
// stops working when i use/add the line above; instead of the post's text, it appears the constructor's html 'hi' :shock:
}
any idea how to solve this?!