1
How to update a DIV without refreshing the entire page?
Formerly in Rails 2.3.10, remote_function was used to update a certain div.
Now in Rails 4.2, since you could no longer 'remote_function' how can I do this?
Ex: When typing an ID
'<%= text_field :individual_id, (something like :update => 'search') %>'
Person name of this ID will appear
div id='search'
'<%=h @molecular_bio.individual && @molecular_bio.individual.name %> '
/div'
I tried using this command in javascript, but I don’t know much about js.
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
var live_search_timer = null;
function start_live_search(){
clearTimeout(live_search_timer);
live_search_timer = setTimeout(function(){
$('#search').fadeOut('slow').(comando para dar um update na div).fadeIn('slow');
}, 2000);
}
</script>
<%= text_field :individual_id, :onKeyPress => "start_live_search()" %>
Have you tried using ajax ( Jquery or Javascript ) to make this update?
– Luiz Picolo
Yes, I tried. I will edit the question with the javascript code I tried
– Michael Allan
Hi Michael, I just answered a question with related content using Jquery and Ajax, I hope to help you, this is the link: http://answall.com/questions/144104/executar-php-sem-update-toda-p%C3%A1gina
– leandroungari