jquery not storing data() values -
what don't understand .data()?
here 2 divs:-
<div id="dataobjects"> <div id="datagetterclone"></div> </div>
here code:-
for (var = 0; < 4; i++) { var elementid = "datagetter"; $("#" + elementid + "clone") .clone() .attr('id',elementid + i.tostring()) .addclass("newitem") .data('dflt_internal_id' ,"") .data('dflt_elem_category' ,"category") .data('dflt_elem_type' ,"standard") .data('dflt_elem_name' ,"getter " + i.tostring()) .data('dflt_elem_top' ,20) .data('dflt_elem_left' ,40) .data('dflt_elem_height' ,60) .data('dflt_elem_width' ,80) .appendto($("#dataobjects")); } // keep track of number of changes saved, , display error later if there none var itemcount = 0; // prepare items inserted var createdon = new date(); $( "#dataobjects > .newitem" ).each( function() { $(this).data("created_by", 57); $(this).data("created_on", createdon); itemcount++; alert($(this).data().count); }); alert("count of inserts " + itemcount);
here fiddle.
why alert($(this).data().count); return "undefined"?
Comments
Post a Comment