Hello Alan, Anthony
Thanks both for your reply !!!
In the meantime I also discovered that I have to use JSON for this specific
situation.
I did it like this :
*Controller :*
def locations():
locations=db(db.value.cat==2).select().*as_list()*
import gluon.contrib.simplejson
return gluon.contrib.simplejson.dumps(locations)
In the script from the view, I could catch the locations like this :
*VIEW:*
var *locations*;
...
* $.getJSON*('/cascade/default/locations',
function(*data*){ *locations=data*;
var select = document.getElementById(reaction_value);
select.options.length = 0; // clear out existing items
for(var i=0; i locations.length; i++) {
var d = locations[i];
select.options.add(new Option(d.val,d.id));
}
});
Best regards,
Mathias
2012/8/19 Alan Etkin spame...@gmail.com:
Do you want to access DAL Row objects in the browser with javascript?
I think that the simplest way is to convert a Rows object to dict and do a
json dump of it, then assign the data to a js variable in the view
controller
import simplejson
myrows = db(query).select().as_dict()
return dict(data=simplejson.dumps(myrows))
view
{{=SCRIPT(var mydata = %s; % data)}}
El viernes, 17 de agosto de 2012 08:52:56 UTC-3, Mathias escribió:
Hi,
How can I catch rows in Javascript code ?
Thanks
Mathias
--
--