I want to update input to a javascript function using a javascriptcallback. the javascript code in the addInput.js script that is pushed to the client does not get executed when triggered from the onAjaxEvent call, but works fine when called from afterRender.
the code looks as follows:
public void onAjaxEvent(final String input) {
ajaxResponseRenderer.addCallback(new JavaScriptCallback() {
public void run(JavaScriptSupport jss_) {
addInput(jss_, input);/* javascript never gets executed */
}
});
}
protected void addInput(JavaScriptSupport jss_, String input) {
JSONObject config = new JSONObject();
config = new JSONObject();
config.put("arg", input);
jss_.require("addInput").invoke("publicFunc").with(config);/* publicFunc never gets executed when called from onAjaxEvent but works fine when called from afterRender */
}
void afterRender() {
JSONObject config = new JSONObject();
javaScriptSupport.require("mainScript").with(config);
addInput(javaScriptSupport, "this call works fine");
}
the addCallback-construct is based on Tapestry 5.4 call jquery more than once
I am using tapestry5-jquery 4.0.0 and tapestry5.4.0 on java1.7. the problem seems to be specific to tapestry 5.4.0, as the same construct where the addInput is a simple addScript("alert('it works!')"); works just fine...
thanks for your feedback!