PDA

View Full Version : AutoRefreshing JSonViews



javajunky
17 Jan 2007, 2:42 PM
I'm sorry for yet another daft post, aI missing a really obvious way to mark JsonViews as 'auto-refresh'. I can't seem to spot a config parameter for it, nor can I see from the docs a way to get hold of an associated UpdateManager for the object (is there one? )

Just for reference the code I'm using for the initial display of the json-view is as follows:


var view = new YAHOO.ext.JsonView('Container', '<div>{foo} - {bar}</div>', { multiSelect: true, jsonRoot: 'data' });
view.load('data.html');


Where data.html contains:

{"data":[{"foo":"poo","bar":"poop"}, {"foo":"boo","bar":"boop"}]}

Now this works perfectl and my template is rendered, bonus :) But now I'd like to change it so if data.html is changed, then the rendered view would automatically change to represent it . Am I approaching this correctly ? Would I be better off using a raw UpdateManager, and returning the pre-rendered divs , rather than the JSON?

Sorry if this is stupid!

javajunky
18 Jan 2007, 4:35 AM
Just for future reference in case anyone else wanted the same behaviour, the following appears to work just fine (for a 5 second automatic refresh):


var view = new YAHOO.ext.JsonView('Container', '<div>{foo} - {bar}</div>', { multiSelect: true, jsonRoot: 'data' });
view.el.updateManager.showLoadIndicator= false;
view.load({url:'data.html', nocache: true});
view.el.updateManager.startAutoRefresh(5);


Note I also disabled the 'showLoadIndicator' to avoid the flicker when it pops up the 'Loading' text by default.[/quote]

jax
20 Jun 2007, 7:55 AM
you can do like this


var view = new YAHOO.ext.JsonView('Container', '<div>{foo} - {bar}</div>', { multiSelect: true, jsonRoot: 'data' });
view.el.updateManager.showLoadIndicator= false;
view.load({url:'data.html', nocache: true});
view.el.updateManager.startAutoRefresh(5,'data.html');