3

I am trying to use update some calculations everytime a person modifies a text field. I have many question about how to know the id text field, how to store it in a variable, etc. I am a newbie with ruby and javascript and there are many questions. Could you please tell me where I can find more information that explains step by step how to proceed with this?

Thank you very much.

    1 Answer 1

    4

    I highly recommend using jQuery with Ruby on Rails... it makes this sort of thing much easier, and is going to be the standard as of the next version (3.1).

    In jQuery, you do something like:

    $('#my_field').change(function() { $('#result').val(function() { do something... }); }); 

    And you can use a js.erb template to embed Ruby in the JS to get data from the controller. Ryan Bates' Railscasts series has several examples of using Javascript in RoR for dynamic content.

    Also, NetTuts+ has this tutorial for using Unobtrusive JavaScript in Rails 3.

    2
    • Jason, I aprreciate your answer. I thinks this is going to be very usefult. Thank you very much.CommentedMay 10, 2011 at 17:24
    • 3
      I hate to say it, but... if it ends up useful, could you accept and/or upvote my answer? Kinda how the site works... either way, glad you liked it, and wish you the best of luck. And feel free to contact me if you have further questions (although posting them to SO would probably be quicker!)CommentedMay 11, 2011 at 1:25

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.