Tuesday, April 16, 2013

[Rails] Re: updaing a page continuously using ajax

Deepak A. wrote in post #1105859:
> My question, Is it possible to make the date to display in text field
> continuously by pressing the button only once? I tried calling the
> Controller method inside a loop and ended with Double render error. is
> it correct way or to make changes in view file?

You need a bit of JavaScript to accomplish what you want. Read up on
setInterval() function:

http://www.w3schools.com/jsref/met_win_setinterval.asp

Then use JQuery to update your input field in the function called each
time the setInterval() fires:

$('#get_date').val(current_date);

How you get "current_date" is up to you. You can get the current date
directly in JavaScript or get it from the server using AJAX (Jquery).

http://api.jquery.com/jQuery.get/

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate