So I have been at this all day. I am trying to trigger an Ajax request and subsequent dialog popup in response to a change in a Select box. Heres what Ive got: <%= select_tag :player, options_for_select(...), :onchange => "Ajax.Request(this.getValue(), { onSuccess: \"new Dialog().showMessage(''Dialog'', ''Ok''); return false;\" });" %> (the values of the select items are URLs) The logs show the query runs and returns successfully, but I cannot get anything to happen beyond that. There is nothing in the JS error console. Can anyone see whats wrong with the above? Alan. -- <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" alt="Wikipedia Affiliate Button" src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" /></a>
It''s supposed to be FBJS ... alert doesn''t work in FBJS (AFAIK) so I see people recommending dialogs as a replacement. Alan. Bosco So wrote:> Is the following line supposed to be JavaScript? If so, try changing it > to */alert(''Ok''); return false;/* > > new Dialog().showMessage(''Dialog'', ''Ok''); return false; > > > -- Bosco > > > On Tue, Jan 6, 2009 at 3:46 PM, Alan Larkin <alan.larkin at gmail.com > <mailto:alan.larkin at gmail.com>> wrote: > > So I have been at this all day. I am trying to trigger an Ajax > request and subsequent dialog popup in response to a change in a > Select box. Heres what Ive got: > > <%= select_tag :player, options_for_select(...), > :onchange => "Ajax.Request(this.getValue(), > { onSuccess: \"new Dialog().showMessage(''Dialog'', ''Ok''); return > false;\" });" %> > > (the values of the select items are URLs) > > The logs show the query runs and returns successfully, but I cannot > get anything to happen beyond that. There is nothing in the JS error > console. > > Can anyone see whats wrong with the above? > > Alan. > > -- > <a href="http://wikimediafoundation.org/wiki/Donate/en"><img > border="0" alt="Wikipedia Affiliate Button" > src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" > /></a> > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org <mailto:Facebooker-talk at rubyforge.org> > http://rubyforge.org/mailman/listinfo/facebooker-talk > >-- <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" alt="Wikipedia Affiliate Button" src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" /></a>
You don''t seem to be using the FBJS ajax calls, is that intentional? http://wiki.developers.facebook.com/index.php/FBJS#AJAX Lee. 2009/1/6 Alan Larkin <alan.larkin at gmail.com>:> So I have been at this all day. I am trying to trigger an Ajax request and > subsequent dialog popup in response to a change in a Select box. Heres what > Ive got: > > <%= select_tag :player, options_for_select(...), > :onchange => "Ajax.Request(this.getValue(), > { onSuccess: \"new Dialog().showMessage(''Dialog'', ''Ok''); return > false;\" });" %> > > (the values of the select items are URLs) > > The logs show the query runs and returns successfully, but I cannot get > anything to happen beyond that. There is nothing in the JS error console. > > Can anyone see whats wrong with the above? > > Alan. > > -- > <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" > alt="Wikipedia Affiliate Button" > src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" > /></a> > _______________________________________________ > Facebooker-talk mailing list > Facebooker-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/facebooker-talk >-- Lee Mallabone. Crossbone Systems Ltd. http://www.crossbonesystems.com/ http://www.fonicmonkey.net/ http://CambridgeWebHeads.ning.com/
Im thinking that this might be less wrong. <fb:js-string var="successCallback"> new Dialog().showMessage(''Dialog'', ''Ok''); return false; </fb:js-string> <%= select_tag :player, options_for_select(...), :onchange => "Ajax.Request(this.getValue(), { onSuccess: successCallback });" %> because I dont think the variables and functions in my original onSuccess code were being subjected to FBJS renaming. I am _guessing_ that using fb:js-string to prepare the code takes care of this, but there is still nothing happening in response to a successful Ajax request. Alan Larkin wrote:> So I have been at this all day. I am trying to trigger an Ajax request > and subsequent dialog popup in response to a change in a Select box. > Heres what Ive got: > > <%= select_tag :player, options_for_select(...), > :onchange => "Ajax.Request(this.getValue(), > { onSuccess: \"new Dialog().showMessage(''Dialog'', ''Ok''); return > false;\" });" %> > > (the values of the select items are URLs) > > The logs show the query runs and returns successfully, but I cannot get > anything to happen beyond that. There is nothing in the JS error console. > > Can anyone see whats wrong with the above? > > Alan. >-- <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" alt="Wikipedia Affiliate Button" src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" /></a>
Emmm ... Im using the stuff in facebooker.js (http://github.com/mmangino/facebooker/tree/master/generators/facebook/templates/public/javascripts/facebooker.js) which uses the FBJS stuff ... just because its there, and it shields me a bit from the javascript, which is not my strong suit. Alan. Lee Mallabone wrote:> You don''t seem to be using the FBJS ajax calls, is that intentional? > http://wiki.developers.facebook.com/index.php/FBJS#AJAX > > Lee. > > > 2009/1/6 Alan Larkin <alan.larkin at gmail.com>: >> So I have been at this all day. I am trying to trigger an Ajax request and >> subsequent dialog popup in response to a change in a Select box. Heres what >> Ive got: >> >> <%= select_tag :player, options_for_select(...), >> :onchange => "Ajax.Request(this.getValue(), >> { onSuccess: \"new Dialog().showMessage(''Dialog'', ''Ok''); return >> false;\" });" %> >> >> (the values of the select items are URLs) >> >> The logs show the query runs and returns successfully, but I cannot get >> anything to happen beyond that. There is nothing in the JS error console. >> >> Can anyone see whats wrong with the above? >> >> Alan. >> >> -- >> <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" >> alt="Wikipedia Affiliate Button" >> src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" >> /></a> >> _______________________________________________ >> Facebooker-talk mailing list >> Facebooker-talk at rubyforge.org >> http://rubyforge.org/mailman/listinfo/facebooker-talk >> > > >-- <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" alt="Wikipedia Affiliate Button" src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" /></a>
Sigh ... facebooker.js#Ajax.Updater expects a function for onSuccess, not a String ... <%= select_tag :player, options_for_select(...), :onchange => "Ajax.Request(this.getValue(), { onSuccess: function(data) { new Dialog().showMessage(''Dialog'', ''Hello World.''); return false; }});" %> does it XO Alan. Alan Larkin wrote:> Im thinking that this might be less wrong. > > <fb:js-string var="successCallback"> > new Dialog().showMessage(''Dialog'', ''Ok''); > return false; > </fb:js-string> > > <%= select_tag :player, options_for_select(...), > :onchange => "Ajax.Request(this.getValue(), { onSuccess: > successCallback });" %> > > because I dont think the variables and functions in my original > onSuccess code were being subjected to FBJS renaming. I am _guessing_ > that using fb:js-string to prepare the code takes care of this, but > there is still nothing happening in response to a successful Ajax request. > > Alan Larkin wrote: >> So I have been at this all day. I am trying to trigger an Ajax request >> and subsequent dialog popup in response to a change in a Select box. >> Heres what Ive got: >> >> <%= select_tag :player, options_for_select(...), >> :onchange => "Ajax.Request(this.getValue(), >> { onSuccess: \"new Dialog().showMessage(''Dialog'', ''Ok''); return >> false;\" });" %> >> >> (the values of the select items are URLs) >> >> The logs show the query runs and returns successfully, but I cannot >> get anything to happen beyond that. There is nothing in the JS error >> console. >> >> Can anyone see whats wrong with the above? >> >> Alan. >> > >-- <a href="http://wikimediafoundation.org/wiki/Donate/en"><img border="0" alt="Wikipedia Affiliate Button" src="http://upload.wikimedia.org/wikipedia/foundation/5/58/2008_fundraiser_micro_button-en.png" /></a>