Re: link_to_remote :success not working ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: link_to_remote :success not working ?

parkert
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 <[hidden email]> 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
> [hidden email]
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


--
Parker Thompson
http://www.parkert.com/
510.541.0125
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: link_to_remote :success not working ?

Sam Stephenson
Hi,

On 10/26/05, Romuald du Song <[hidden email]> wrote:
> 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.

The :success and :failure callbacks are triggered *before* the :update
element's innerHTML is replaced. Assuming the checkItems function does
something to the 'topinfo' element, that element is being replaced
after checkItems is called, which explains why it appears to do
nothing.

I can provide more help if you'll explain in more detail what you're
trying to do.

--
sam
_______________________________________________
Rails mailing list
[hidden email]
http://lists.rubyonrails.org/mailman/listinfo/rails
Loading...