File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ruby and the fly likes make Dynamic ID available to js.erb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Languages » Ruby
Bookmark "make Dynamic ID available to js.erb" Watch "make Dynamic ID available to js.erb" New topic
Author

make Dynamic ID available to js.erb

santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
I have a sample App.The view is:


To correspond to this, I have increment.js.erb with the following:



Now, when button is clisked, I want to replace the related number and the +1 button with some message like "Incremented".
The problem here is, using static IDs doesn't work for very obvious reason.And the same goes for class.
One very good idea is to generate dynamic IDs, e.g.,
But, how to make this dynamic ID available to the js.erb?
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1347
    
  13
The controller knows about the dynamic number, right? Could it assign that to the template?



santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
It doesn't work.
There's a gem available for this purpose called jsvars.
I'll try it.
santoshkumar savadatti
Ranch Hand

Joined: Apr 27, 2010
Posts: 95
It doesn't work.
There's a gem available for this purpose called jsvars.
I'll try it.


Your suggestion worked fine Katrina.I had made some mistakes.Now i did this:
in the view, i had to say
Then in the controller,
And in the js.erb,

That was all needed.
Thanks.
Katrina Owen
Sheriff

Joined: Nov 03, 2006
Posts: 1347
    
  13
Glad it helped!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: make Dynamic ID available to js.erb
 
Similar Threads
Generating OL LI tree structure from a recursive method call
Passing Parameters between the tabs in single JSP
Render recaptcha via js.erb
set values in a table from other
need help for critical path analysis in java