Reputation: 6894
I have a json structure is like this..
{
"event": [
{
"ids": [
"100",
"101"
],
"eventlist": [
{
"title": "Title1",
"day": "Fri",
"date": "2",
"endDate": "6",
"month": "1"
},
{
"title": "Title2",
"day": "Mon",
"date": "5",
"endDate": "5",
"month": "1"
}
]
}
]
}
HTML Handlebar template..
{{#event}}
{{#each eventlist}}
<li>
<div>{{title}}</div>
<div>{{day}}</div>
<div>{{month}}</div>
</li>
{{/each}}
{{/event}}
How can i store the values title,day,month as a jquery.data() value into the li , so that i can access the data of li using li.data()
Upvotes: 1
Views: 716
Reputation: 108500
Just add them as data attributes:
<li data-title="{{title}}" data-day="{{day}}" data-month="{{month}}">
jQuery will be able to access them through .data()
:
var title = $('li').data('title');
Upvotes: 3