that is the html code I do send after an ajax.updater call. ----------------- <div id="parent"> <div id="the_id_xyz" > here html </div> <script type="text/javascript"> getData=function(){ return {id:''the_id_xyz'',some_more_data:''data data data''}; } </script> --------------------- further I do have my ajax updater like build laike this function myUpdateFunc (){ var myAjax = new Ajax.Updater( ''parent'', url, { method: ''get'', parameters: pars, insertion:Insertion.Bottom, onComplete:registerHtmlCode evalScripts: true }); } and somwhere else function registerHtmlCode(){ var newData=getData(); ... do some more funny things with the newData } from prototype API doc: "The local scope will be that of Prototype''s internal processing function. Anything in your script declared with var will be discarded momentarily after evaluation, and at any rate will be invisible to the remainder of the page scripts." So believing this I do get by the first call to myUpdateFunc the callback function do get the correct data out of the getData function. The second time a call myUpdateFunc the value I do get back out of getData is the data corresponding to the first call. My reading of the doc let me think that once the getData is reevaluted the value should be the value send with the html code. I want to have with the call to getData() some info about what I just inserted, this without having to query my DOM. Is my reading of the doc correct. Has this construct some chances to work. Thanks for any explanation, hint, remarks cedric --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
cedric, Unless your method, registerHtmlCode, is altering what getData returns (it doesn''t look like it, from your example code), then I don''t see how the result from calling getData will ever change. Can you post the real code you are using instead of the simplified version? -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
here the ajax updater -------------------- function getSnippsetAlbum(albumId){ var url = ''/snippset/albumpicture/''+ albumId ; var pars = null; var myAjax = new Ajax.Updater( ''album'', url, { method: ''get'', parameters: pars, insertion:Insertion.Bottom, onComplete:registerAlbum, evalScripts: true }); } -------------------------- one result to a call -------------------- <div id="album_c487feedc3907d40982f96a39e795b96" class="album" style="position: relative; width: 100%; display: none;" > <div id="thumb_ca6d0b1d9691ad8fee73b41b415bd689_10" class="thumbnail" style="position: relative;"></div><div id="thumb_c99f46ba3eea5e39f9a5e0b9252bcef0_11" class="thumbnail" style="position: relative;"></div> </div> <script type="text/javascript" > getData=function(){ return {id:''album_c487feedc3907d40982f96a39e795b96'',name:''my Name'' };; } </script> -------------------------- another call -------------------------- <div id="album_4ae22d06a2546888405b63cc38ec07bd" class="album" style="position: relative; width: 100%; display: none;" > <div id="thumb_8c39d640d854c5b42cada751ae4e89e6_10" class="thumbnail" style="position: relative;"></div> <div id="thumb_c99f46ba3eea5e39f9a5e0b9252bcef0_20" class="thumbnail" style="position: relative;"></div> <div id="thumb_c99f46ba3eea5e39f9a5e0b9252bcef0_25" class="thumbnail" style="position: relative;"></div> </div> <script type="text/javascript" > getData=function(){ return {id:''album_4ae22d06a2546888405b63cc38ec07bd'',name:''my another Name'' };; } </script> ------------------------------ and here the callBack ------------------------------ function registerAlbum(){ var albumData=getData(); albumColl.add(new Album(albumData)); } ------------------------------- that is it folks cedric --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Instead of redefining the getData function on every request why not just make getData return a dynamic object instead of one with hardcoded values? What you''re probably running into is the function is not getting redefined until after the request is completed, so when you call getData, you''ll always be one step behind. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The getData definition is put together on the server. There I know everything about what I''m sending to the client. So I trying not to do the same work twice once on the server, once on the client side. On Jan 15, 6:57 pm, "Justin Perkins" <justinperk...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Instead of redefining the getData function on every request why not > just make getData return a dynamic object instead of one with > hardcoded values?I don''t quite see what you mean by dynmaic object. I wanted, with this construct, to avoid pulling the data out of the DOM piece I just included: As I know it before hand on the server. It ''s like a data accessor on the html snippset.> > What you''re probably running into is the function is not getting > redefined until after the request is completed, so when you call > getData, you''ll always be one step behind.As I call it after completion with the callback it should be alright. I''m still perplex!!!> > -justin--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 15, 2008 12:45 PM, ced <cedric-nKMm2dXlJaxWk0Htik3J/w@public.gmane.org> wrote:> I don''t quite see what you mean by dynmaic object. I wanted, with this > construct, to avoid pulling the data out of the DOM piece I just > included: As I know it before hand on the server. It ''s like a data > accessor on the html snippset.I''m not really sure what you''re trying to do here, but maybe you could just set some variables and have your function return those instead of redefining the function, such as: var Data = { id:null, name:null, get: function(){ return { id: this.id, name: this.name }; }, set: function( id, name ){ this.id = id; this.name = name; } } Then your Ajax responses would have some JavaScript like: Data.set( ''my new ID'', ''my new name'' ) And your registerAlbum would be modified to be: function registerAlbum(){ var albumData=Data.get(); albumColl.add(new Album(albumData)); } Hope this makes sense. There are many different ways to accomplish what you are trying to do, this is just one example. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
> I''m not really sure what you''re trying to do here, but maybe you could > just set some variables and have your function return those instead of > redefining the function, such as: > > var Data = { > id:null, > name:null, > get: function(){ > return { id: this.id, name: this.name }; > }, > set: function( id, name ){ > this.id = id; > this.name = name; > } > > } > > Then your Ajax responses would have some JavaScript like: > > Data.set( ''my new ID'', ''my new name'' ) > > And your registerAlbum would be modified to be: > > function registerAlbum(){ > var albumData=Data.get(); > albumColl.add(new Album(albumData)); > > } >This seems to be a very good idea. TIMTOWTDI. Your vision of my problem gives me a new insight. thanks, i''ll have a go and keep you/the list posted. have a nice evening/day/whatever cedric --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
The solution having a "dynamical object" proves to be almost satisfatory. The obvious solution is to have the call to registerAlbum in the evaluated script coming with the html snippset. That made my day. Thanks for your vision on my problem. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jan 16, 2008 5:32 AM, ced <cedric-nKMm2dXlJaxWk0Htik3J/w@public.gmane.org> wrote:> That made my > day. Thanks for your vision on my problem.Glad it all worked out. Have a great day. -justin --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---