I''m having the exact same problem with .14.4 and form_remote_tag. I
have a tag:
<%= form_remote_tag(
:update => ''admins'',
:url => { :action => ''add_admin'', :params => {:id
=> @place.id} },
#:complete => "alert(request.status);
\$(''new_user_form'').value = ''''",
:failure => "flash(''failed?'');",
:success => "alert(''success'');"
)
%>
When the form is submitted the admins div updates, however neither
:failure or :success is ever called. If I uncomment :complete I can
watch the status codes (2xx and non 2xx) which the docs say will
trigger these callbacks.
Is anyone using :failure and :success callbacks in their code
successfully? I could alternately return a block of javascript that
updates the correct div and calls calls the right javascript functions
with eval(request.responseText), but this seems like the "right way"
to do things.
Thanks,
pt.
On 10/26/05, Romuald du Song
<rdusong-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hye,
>
> I ''ve used link_to_remote as:
>
> link_to_remote ''All'', :update =>
''topinfo'',
> :url => { :action {
''ajax_all'', :id => @alb },
> :success =>
"checkItems(''select_all'', true)",
> :html => { :action => url_for(:action
> => ''all'', :id=>@alb }
>
> as the docs stated that the :success handler will be call when the
> request is completed and successful.
> But It does''nt seem to work this way. Looking in prototypes
1.4.0_rc1,
> the code does''nt look to work as the doc says.
>
> As a matter of fact, this works:
> link_to_remote ''All'', :update =>
''topinfo'',
> :url => { :action {
''ajax_all'', :id => @alb },
> :complete =>
"checkItems(''select_all'', true)",
> :html => { :action => url_for(:action
> => ''all'', :id=>@alb }
>
> and really do what should be done on '':success'' only.
> That is the doc explains thah :complete will be called whether the
> request is successful or not but in prototype.js you have :
>
> ....
> updateContent: function() {
> var receiver = this.responseIsSuccess() ?
> this.containers.success : this.containers.failure;
>
> var match = new RegExp(Ajax.Updater.ScriptFragment,
''img'');
> var response = this.transport.responseText.replace(match,
'''');
> var scripts = this.transport.responseText.match(match);
>
> if (receiver) {
> if (this.options.insertion) {
> new this.options.insertion(receiver, response);
> } else {
> receiver.innerHTML = response;
> }
> }
>
> if (this.responseIsSuccess()) {
> ^^^^^^^^^^^^^
> if (this.onComplete)
> ^^^^^^^^^^^
> setTimeout(this.onComplete.bind(this), 10);
> }
> ....
>
> Any nice guy to comment on this ?
>
> ---
> Romuald du Song
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
--
Parker Thompson
http://www.parkert.com/
510.541.0125