Topic: onLoading and

Hello everyone.
i hope this topic hasn't been discussed already, i did a search with no results

the problem i have is the following:

i have an invoice that has many invoice rows, all in a view.
I want to do an ajax elaboration onchange on a select inside a row, and disable the select while the request is loading

the big problem is that using helper :loading for remote_functions, the "this" variable refers to the window, and not to the element, as wonderfully explaned here: http://www.quirksmode.org/js/this.html.

because it is a row, it can't have a fix identifier, so i can't get it by id.

How do you think i could resolve the problem?

thank you in advance
Marco

Last edited by vecchiaspugna (2010-06-22 13:36:28)

Re: onLoading and

vecchiaspugna wrote:

Hello everyone.
i hope this topic hasn't been discussed already, i did a search with no results

the problem i have is the following:

i have an invoice that has many invoice rows, all in a view.
I want to do an ajax elaboration onchange on a select inside a row, and disable the select while the request is loading

the big problem is that using helper :loading for remote_functions, the

Hi - your post got truncated by the forum - can you edit it and try again?

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: onLoading and

thanks a lot! i didn't notice it!

now it's ok

Re: onLoading and

You can give the row (or any element) an id.  I have a few tables where i add or delete rows using ajax, where each row represents one particular record/model instance.  In this case i give the row an id of "<model name>_<record id>".  eg

#in quizzes/quiz.html.erb
<tr id="quiz_<%= quiz.id %>">
  #bunch of tds holding data for this quiz go here
</tr>

Then my .js.rjs files which get called after the action operate with this id, eg something like

page.replace "quiz_#{@quiz.id}", :partial => "quizzes/quiz", :locals => {:quiz => @quiz}

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: onLoading and

Thank you!

Yes, a server side identifier for the row could be a solution...

any idea if i can do it client side using $(this)?

Re: onLoading and

vecchiaspugna wrote:

Thank you!

Yes, a server side identifier for the row could be a solution...

any idea if i can do it client side using $(this)?

do what?  i'm confused about what you're trying to do here.

###########################################
#If i've helped you then please recommend me at Working With Rails:
#http://www.workingwithrails.com/person/ … i-williams

Re: onLoading and

do -> access to the dom element where i call the remote_function, using :loading, or :create and so on, only by javascript

thanx