counter is a ruby, server-side variable, evaluated before javascript
code is executed.
You can use a javascript, client-side variable, like in this code (not
tested)
page << “counter = 0”
page.select(‘#mediators li’).each do |t|
page << “counter += 1”
end
Now you must change your mediator partial, in order to use the counter
javascript variable.
counter = 0
page.select(‘#mediators li’).each do |t|
counter += 1
end
(…)
The problem is the counter variable always comes back as “1” no matter
how many
counter is a ruby, server-side variable, evaluated before javascript
code is executed.
You can use a javascript, client-side variable, like in this code (not
tested)
page << “counter = 0”
page.select(‘#mediators li’).each do |t|
page << “counter += 1”
end
Now you must change your mediator partial, in order to use the counter
javascript variable.
counter = 0
page.select(‘#mediators li’).each do |t|
counter += 1
end
(…)
The problem is the counter variable always comes back as “1” no matter
how many
elements there are.
(…)
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.