Hi, i already have played with JSONLiteral, but had no luck. If i do a: retour.put("beforeClose", new JSONLiteral("function(e,m) {alert('About to close this notification!');}"));
it renders: "jGrowlAlertManager" : [ { "dismissURL" : "/index.layout.jgrowl:dismiss", "jgrowl" : { "position" : "center", "beforeClose" : function(e,m) {alert('About to close this notification!');}, "header" : "Error" }}] so without the quotes, but alert is not called. if i do a: retour.put("beforeClose", new JSONLiteral("alert('About to close this notification!')")); it renders: "jGrowlAlertManager" : [ { "dismissURL" : "/index.layout.jgrowl:dismiss", "jgrowl" : { "position" : "center", "beforeClose" : alert('About to close this notification!'), "header" : "Error" }}] but the alert occurs when loading the page and not when closing the alert :-) I already had your suggestion in my focus to provide a function somewhere else and put only the functioncall in the json, but again with no luck: .tml: <script type="text/javascript"> function mybeforeclose(){ alert('About to close this notification!'); } </script> .java: retour.put("beforeClose", new JSONLiteral("mybeforeclose()")); It renders without the qoutes, but it is called when the page is loaded and not when closing the alert. Doing a: retour.put("beforeClose", "mybeforeclose()"); it renders without the quotes, but nothing happens when closing the alert. I also tried without the brackets, all without luck :-( Seems that i am really the only one who is playing with tapestry-jquery jgrowl-alert? I can not believe :-) In addition: the latest jgrowl version is 1.2.13 but tapestry-jquery 3.3.6 uses jgrowl 1.2.6 With kind regards David Am 26.06.2013 20:15, schrieb Thiago H de Paula Figueiredo: > On Wed, 26 Jun 2013 14:51:29 -0300, D.R. <d...@googlemail.com> wrote: > >> whoops, >> >> usually i declare my components in the page class, but in this project i >> wanted to write less code. I've checked the docs about expansions and >> this topic is now clear to me, thank you Thiago for your answer and your >> hint. > > :) > >> >> You was right, i don't get this error anymore, but it still don't work >> properly: >> >> .tml: >> <t:jquery.jgrowl params="jgrowlparams" /> >> >> .java: >> public JSONObject getJgrowlParams() >> { >> JSONObject retour = new JSONObject(); >> retour.put("position", "center"); >> retour.put("header", "Error"); >> retour.put("beforeClose", "function(e,m) {alert('About to close >> this notification!');}"); >> return retour; >> } > > I guess you should use JSONLiteral when passing the function. > Otherwise, it'll be treated as an ordinary string. Please try this and > let us know the result. > > A mostly unrelated hint: instead of passing a function inside a > JSONObject, why don't you create this function in some .js file and > just pass it directly? Something like function myBeforeClose() {...} > in a .js file and then retour.put("beforeClose", "myBeforeClose"). I > haven't tested it, but it may work. Either way, the less JS code you > have in Java classes, putting them on .js files instead, the better. > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org