javascript - Is there a simple way to only reload an element if it content has changed? -


i using rightjs (very similar jquery) on site i'm working on. loading element on page result of request so:

var comp = $('completed_step'); if(comp != null) comp.load("/brew/completed_step"); 

this works trying find way load element if result of request 'brew/current_step' different value loaded in element. there easy way accomplish that?

you need compare value of current element loaded.

var comp2; var comp = $('completed_step'); //i'm assuming refers value if( comp != null || comp != "" ){     comp2 = load("/brew/completed_step"); }  if( comp != comp2 ){     comp = comp2; } 

keep in mind, i'm not familiar rightjs, might wrong, should give right idea.

edit:

it looks xhr module in rightjs takes object allows specify when process has completed.

http://rightjs.org/docs/xhr#load

xhr.load('/some/url', {   onsuccess: function(request) {     //   } }); 

that's example in documentation.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -