[英]Dynamic content from JSON data with Jade, HTML5 and jQuery
I'm getting a junk of JSON data and would like to work with that data without refreshing the site. 我收到大量的JSON数据,并希望在不刷新站点的情况下使用该数据。
There are two divs: 有两个div:
If the user selects an item from the items list, div#item should be displayed instead of div#items with the item data. 如果用户从项目列表中选择一个项目,则应显示div#item而不是包含项目数据的div#items。 In Jade, I have to check if the item data has been defined: 在Jade中,我必须检查是否已定义商品数据:
- if(typeof(item) != 'undefined')
The click is handled by jQuery and I'm filling item
with the corresponding data, hiding #items and showing #item, but due to the if-clause, Jade doesn't get that item
now has a value. 点击是由jQuery处理的,我用相应的数据填充item
,隐藏#items并显示#item,但是由于if子句,Jade无法获得该item
的值。
I really would like to stick to the single request and do most of the data handling on the client-side as every refresh of the page automatically loads all the JSON data again. 我真的很想坚持单个请求,并在客户端进行大多数数据处理,因为页面的每次刷新都会自动再次加载所有JSON数据。 What would be the best solution for that? 最好的解决方案是什么?
Should I put the data into an HTML5 store? 我应该将数据放入HTML5存储区吗?
Thanks 谢谢
I found a workaround by just filling the div from jQuery with the .html() function. 通过使用.html()函数填充jQuery的div,我找到了一种解决方法。 Anything better is highly appreciated. 任何更好的方式都受到高度赞赏。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.