我在javascript中有一个对象,其中包含id,name对,用于标识我的web2py'projects'表中的条目。 在浏览器中,我使用python使用条目填充视图
{{=A('+ Create New Project', _href=URL("createProject"))}} {{for proj in projects:}} {{=A(proj.name, _href=URL("showImages", vars=dict(projectId=proj.id)))}} {{pass}}我使用json将id的字典,项目的名称从python传递到javascript,现在我需要在javascript中实现链接列表的创建,因为我需要能够按下按钮来编辑列表。 我可以通过访问该对象
for (var id in obj){ //id gives the project id and obj[id] gives the projectname }如何使用名称作为文本创建列表,“showImages”控制器作为URL,项目ID作为请求变量? 谢谢
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
最满意答案
您可以对链接进行硬编码。
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); }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); }更多推荐
发布评论