f ajax event,javascript - onevent on f:ajax causes model to not getting updated - Stack Overflow

I've added TinyMCE on a website (JSF-2, Tomcat 7, Mojarra 2.1.6). When a user clicks on a 'refresh' button the html text inside the editor is parsed and printed somewhere else on the page.

I have to turn off TinyMCE before the Ajax request (otherwise I will end up with two editors). This is also recommended in the TinyMCE documentation.

So I added an f:ajax event to the button:

the javascript functions are called properly:

function cleanupRte() {

tinyMCE.triggerSave();

return true;

}

and the onevent method:

function disposeTinyMce(e) {

if(e.status == 'begin') {

tinyMCE.triggerSave();

var elem = document.getElementById("mainForm:rteExtAdr:input");

alert(elem.value);

tinyMCE.execCommand('mceRemoveControl', false, 'mainForm:rteExtAdr:input');

}

if(e.status == 'complete') {

}

if(e.status == 'success') {

tinyMCE.execCommand('mceAddControl', false, 'mainForm:rteExtAdr:input');

}

return true;

}

which disables the editor and adds it back to the page. This is working fine.

The problem is the model is not updated with the value from the textfield although the alert shows the correct value. The request also contains the 'old' value from the textfield.

Is there something that would prevent the ajax call to see the current form values?

or does it read the values before it executes the onevent function?

If I remove the f:ajax tag completely the model is updated but then I have the issues with the TinyMce editor getting duplicated after the response.

the init call:

tinyMCE.init({

mode : "textareas",

theme : "advanced",

editor_selector : "sesamWysiwyg",

language : "de",

force_br_newlines : true,

force_p_newlines : false,

inline_styles : false,

forced_root_block : '', // Needed for 3.x

plugins : "autolink,lists,style,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,searchreplace,print,paste,directionality,noneditable,visualchars,nonbreaking,xhtmlxtras,wordcount,advlist",

formats : {

underline : {inline : 'u', exact : true},

strikethrough : {inline : 'del', exact : true}

},

theme_advanced_buttons1 : "bold,underline,strikethrough,|,cut,copy,paste,pastetext,pasteword,search,replace,|,undo,redo,|,code,removeformat,|,charmap",

theme_advanced_buttons2 : "",

theme_advanced_buttons3 : "",

theme_advanced_buttons4 : "",

theme_advanced_toolbar_location : "top",

theme_advanced_toolbar_align : "left",

content_css : "css/content.css",

});

Any ideas or suggestions would be great!

thanks :)

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值