Ciao, i have a anchor based on this code: html anchor script: (html jQuery this button text: true; primaryIcon: 'ui-icon-circle-plus' title: 'Successivo'); onClick: (html jQuery ajax ( html jQuery ajax script: [ :s | s << (s jQuery: #'base') load html:[:h| "A" self incrementaIndex: true. "B1" (self renderingBaseOn: h)]. s << (s jQuery: #'orarioRiferimento') load html:[:h| "B2" ( self renderOrarioRiferimentoOn: h)]]); with: '>'. My objective when a user click on this anchor is: A) update a index with the self incrementaIndex: true. B1) update the div #base with: self renderingBaseOn: h B2) update the div #orarioRiferimento with: self renderOrarioRiferimentoOn: h Where the B1 - B2 rendering is based on the index state. Now i have a strange behavior because sometime the B2 div #orarioRiferimento renderings is not aligned to the index. As if the onClick script action is not execute in the definition sequence. Any suggestions ? What is the right definition to solve this problematic type ? Thanks, Dario _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
You don't need to use load in this context as it is creating additional ajax requests. Try the following.
onClick: (html jQuery ajax script: [ :s | s << (s jQuery: #'base') html:[:h| "A" self incrementaIndex: true.
"B1" (self renderingBaseOn: h)].
s << (s jQuery: #'orarioRiferimento') html:[:h| "B2" ( self renderOrarioRiferimentoOn: h)]]);
On 5 June 2013 10:40, <[hidden email]> wrote:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by dtrussardi@tiscali.it
Hi Dario,
I think the trouble is that when you have two or more ajax scripts to be run you are not guaranteed which will run first. If you use a callback and send serializeThis to the ajax object, it runs before any scripts:
html anchor
callback: [ self setIndex: aValue ];
onClick: (html jQuery ajax
serializeThis;
script: [ :s | (s jquery: anId) html: [ :h | self renderStuffOn: h ].
s << (s jQuery: anId2) html: [ :h | self renderSomeOtherStuffOn: h ] ]...
Regards,
John
On Wed, Jun 5, 2013 at 4:40 AM, <[hidden email]> wrote:
-- jmck.seasidehosting.st _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
John,
there's no use in serializing an anchor. You can serialize a form in order to transport the values of the form to the server, but there's no other use for that (http://api.jquery.com/serialize/) As for the order of javascript, the script that's created here performs a single Ajax request to the server (by calling #ajax), responding with a script that replaces the contents of two html nodes.
I think there's some confusion as to when the different blocks are executed. The script block [:s | …. ] is executed in response to the ajax request. It immediately executes the two html blocks [:h | … ] and the result is part of the script that the script-block produces. When you debug that using Chrome or Firebug, check the network panel for the traffic that's generated. You should only see one get request and the response of that request is javascript code like jQuery("#id1").html("yadayada"); jQuery("#id2").html("yagayaga"); Now in the Original example there were some #load calls, that generate extra ajax requests. These request could lead to load-order conflicts. But as Ryan already pointed out, they only make things more complicated in this context. Kind Regards Karsten --
Karsten Kusche - Dipl. Inf. (FH) - [hidden email] Georg Heeg eK - Köthen Handelsregister: Amtsgericht Dortmund A 12812 Am Mittwoch, 5. Juni 2013 um 13:21 schrieb John McKeon:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by John McKeon
Ciao,
with the Ryan changes all works fine.
I think the use of callback is more clear but some test id do don't solve the problematic. At the top of my rendering i have this code : html document addLoadScript: (html jQuery ajaxSetup
onError: (html javascript
alert: 'The session erase a jq error.' )) and when i work with callback the system erase the alert. How i can use the callback in this problematic, or the Ryan indications is the only solution. Thanks, Dario
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Hi Dario,
please read the documentation about ajaxError: http://api.jquery.com/ajaxError/ it suggests that you check the parameters to the function. You can either convert the script to a function by sending #asFunction: and provide an array of variable names, or you add that script in your file library like so: jQuery(function($){ $(document).ajaxError(function(event, jqXHR, ajaxSettings, thrownError) { alert("error " + thrownError); }); });
That'll also register the event handler and be not so difficult to read. Downside is that you cannot easily send that back to the server as you don't have a callback URL at hand, but for debugging purposes that should be fine. Kind Regards Karsten Karsten Kusche - Dipl. Inf. (FH) - [hidden email] Georg Heeg eK - Köthen Handelsregister: Amtsgericht Dortmund A 12812 Am Mittwoch, 5. Juni 2013 um 14:55 schrieb [hidden email]:
_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by dtrussardi@tiscali.it
dtrussardi <at> tiscali.it <dtrussardi <at> tiscali.it> writes:
> ... Hi Dario, I am very new at this, and I am very interested in a snipet of your working solution. Thanks very much.. _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Ciao,
> Hi Dario, > I am very new at this, and I am very interested in a snipet of your working > solution. > Thanks very much.. this is my code: renderContentOn: html " rendering button for gestione scroll fascie orarie " html div class:'floatLeft'; with:[ html anchor script: (html jQuery this button text: true; primaryIcon: 'ui-icon-circle-minus'); title: 'Precedente'; onClick: ( html jQuery ajax script: [ :s | s << (s jQuery: #'baseid') html:[:h| "A manage counter" self incrementaIndex: false. "A1 first update " self renderingBaseOn: h]. s << (s jQuery: #'orarioRiferimentoid') html:[:h| "B second update " ( self renderOrarioRiferimentoOn: h)]] ); with: '<']. " The first ID update by A1" html div id: #'baseid' with:[ self renderingBaseOn: html]. "The second ID update by B" html div id: #'orarioRiferimentoid'; class:'floatLeft';class: 'orarioFont'; with: [self renderOrarioRiferimentoOn: html]. Where renderingBaseOn: and renderOrarioRiferimentoOn: render some data based on the state of index update by A I hope it is enough to understand. Dario_______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
dtrussardi <at> tiscali.it <dtrussardi <at> tiscali.it> writes:
Thank you Dario. I am working on understanding it. Sees that the second with: is incorrect, but I will get past this. Thanks _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |