On Mon, Oct 22, 2012 at 4:39 AM, bhorvat <horvat.z.bo...@gmail.com> wrote: > Howard Lewis Ship wrote >> What if the function already existed on some global object? > > The function should not exist anywhere before my code.
Well, change that. Have you Ajax response load a library containing the function. > Here is what happens. > The page is loaded, I click a link which refreshes a zone and then it > reveals a textfield with autocomponent mixin. I am passing that JSONObject > to options of the autocomponent mixin that will assign a function to the > select event of the autocomponent (my idea is to submit the form on select - > well to submit what the users has selected) > > public JSONObject getAutoUsersParams() { > JSONObject params = new JSONObject(); > params.put("select", new JSONLiteral("function (event,ui) > {alert(1)}")); > return params; > } > > However the zone is simply not refreshed. But to answer the original > question since the function is then inserted for the first time it does not > exist anywhere else. When I go to debug I can see that on the server side > everything happens as it should. Also the zone is refreshed if I dont pass > the JSONLiteral. Also if I set that the textfield is visible at first load > then the function is passed as it should, when I select the link to > hide/show the edit mode it hides it, but then it wont show it on my next > click. > > So the problem is only when I want to refresh the zone and I pass the > JSONLiteral > > > Howard Lewis Ship wrote >> >> What if the JSONObject you pass in is not passed directly to autocommit >> code? > > hm...since I am not that good with js I have no idea what autocommit code > is? Any suggestion how I can check this or what it is? > > > Howard Lewis Ship wrote >> >> So you pass what I call a "spec", and it builds the options for the >> autocommit itself. You don't specify a function, you specify a >> function name or reference. > > I am not quite positive what you want to explain to me here but if I > understood you correctly this approach is not good for me. I dont want to > execute the function when I refresh a zone I just want to pass the function > to the select event of the autocomplete mixin. So calling addScript and > passing a function sadly wont work for me > > > Howard Lewis Ship wrote >> >> I'm not exactly sure why the Ajax case fails; I suspect something in >> the Prototype portion of the pipeline is sanitizing the JSONObject to >> defeat what you are attempting. I always start in the Network tab, to >> see exactly what is being passed down to the client (I sometimes use >> curl from the command line just to be certain there isn't some browser >> caching getting in the way). > > I am using jquery (probably should have mention this before). In the Network > tap I dont see anything wrong. Just that event is being triggered. However > in the console I do see some error > > Communication with the server failed: null t5-console-jquery.js:64 > error t5-console-jquery.js:64 > $.extend.invokeLogger tapestry-jquery.js:160 > $.extend.error tapestry-jquery.js:120 > $.tapestry.utils.ajaxFailureHandler tapestry-jquery.js:1103 > fire jquery-1.7.2.js:1075 > self.fireWith jquery-1.7.2.js:1193 > done jquery-1.7.2.js:7540 > callback jquery-1.7.2.js:8324 > Ajax failure: Status 200 for #{request.url}: null > Ajax failure: Status 200 for #{request.url}: null t5-console-jquery.js:56 > > The cash is definitely not the problem I have checked that > > tnx for help > > > > -- > View this message in context: > http://tapestry.1045711.n5.nabble.com/JSONLiteral-breks-zone-refresh-tp5717101p5717128.html > Sent from the Tapestry - User mailing list archive at Nabble.com. > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > -- Howard M. Lewis Ship Creator of Apache Tapestry The source for Tapestry training, mentoring and support. Contact me to learn how I can get you up and productive in Tapestry fast! (971) 678-5210 http://howardlewisship.com --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org