Reputation: 124
I have an object in the javascript which contains id, name pairs which identify entries in my web2py 'projects' table. In the browser, I populate the view with the entries using python
{{=A('+ Create New Project', _href=URL("createProject"))}}
{{for proj in projects:}}
{{=A(proj.name, _href=URL("showImages", vars=dict(projectId=proj.id)))}}
{{pass}}
I used json to pass the dictionary of id, names of the projects from python to javascript and now I need to implement the creation of the list of links in javascript because I need to be able to edit the list with button presses. I can access the object by
for (var id in obj){
//id gives the project id and obj[id] gives the projectname
}
How would I create the list using the name as the text, "showImages" controller as the URL, and the project id as the request variable? Thank you
Upvotes: 0
Views: 42
Reputation: 1183
You can hardcode the link.
var link_array;
var link;
for (var id in obj){
//id gives the project id and obj[id] gives the projectname
link = '<a href="/application_name/contoller_name/showImages/' + id + '">'+ obj[id]+'</a>';
link_array.push(link);
}
Upvotes: 0