Okay so this code:
<div class="summary-block" data-block-json="{"pageSize":4,"acceptTypes":["gallery","blog","projects","calendar"]}">
I’m trying to use some jQuery to accomplish something like this:
$(".summary-block").data('block', 'pageSize').each(function() {
$('.summary-item').wrap('<div class="col sqs-col-3 span-3"></div>');
$('.col > .summary-item').wrap('<div class="newSummary"></div>');
});
Now the code works 100%, but not 100% in terms of what I’m trying to ask it. How can I make it so its like:
$(".summary-block").data('block', 'pageSize':4).each(function() {
$('.summary-item').wrap('<div class="col sqs-col-3 span-3"></div>');
$('.col > .summary-item').wrap('<div class="newSummary"></div>');
});
Notice the :4 this must be included somehow in my code. Please help. Thanks!
You don’t filter the elements, you are only setting new
dataattributes, not selecting the elements that have specificdataattributes, also in youreachfunction context you should usethiswhich refers to the current element not$('.summary-item')and you should codedata('block-json'), notdata('block'). You can usefiltermethod.http://jsfiddle.net/xw2vN/