Hi,
I have the following code snippet to update a wymeditor instance:
- Code: Select all
var editor = $.wymeditors($('.wym_box').index($('#' + response.messagearea).next('.wym_box')));
editor.html(editor.html() + response.template);
if I add editor.html() alerts before and after the editor.html() call above, it seems that (1) I've found the good wymeditor instance, and that its contents gets updated. Still, nothing shows up on my screen.
The full code is a bit longer, but here is it in case someone would be interested.
If I disable wymeditor (by uncommenting its initialisation code), then the underlying textarea is updates as it shold.
- Code: Select all
var TemplateLoader = {
init: function(){
var next = gettext('Next');
if ($('#jDialog').length != 1) $('body').append('<div id="jDialog"><form></form></div>');
$('#jDialog').dialog({
bgiframe: true,
autoOpen: false,
height: 300,
modal: true,
buttons: {
next: function() {
var query = $('#jDialog form').serialize();
$(this).dialog('close');
$.getJSON(document.location.pathname + 'template/', query,
function(data){
TemplateLoader.process_response(data)
});
},
Cancel: function() {
$(this).dialog('close');
}
},
})
},
load_template: function(template, messagearea) {
$.getJSON(document.location.pathname + 'template/', {
'template_name': template,
'messagearea': messagearea,
},
function(data){
TemplateLoader.process_response(data);
})
},
process_response: function(response) {
if (typeof(response.template) != 'undefined') {
if ($('.wym_html_val').length > 0) {
TemplateLoader.update_wym(response);
} else {
$('#' + response.messagearea).val($('#' + response.messagearea).val() + response.template);
};
return;
};
$('#jDialog form').html(response.input);
$('#jDialog').dialog('open');
return;
},
update_wym: function(response) {
var editor = $.wymeditors($('.wym_box').index($('#' + response.messagearea).next('.wym_box')));
editor.html(editor.html() + response.template);
},
}
$(document).ready(function(){
TemplateLoader.init();
$('.template_button').click(function(event){
TemplateLoader.load_template($(this).prev('select').val(), $(this).parents('fieldset').find('textarea:first').attr('id'));
event.preventDefault();
});
});
could someone point me out the problem?