I have the following HTML generated on the server through an AJAX call. Of course there is a lot more than this but the following line is relevant:
<div id="mydiv" DATA-mylist='[ [0,0], [1,0], [4,1], [6,1], [7,1], ]'>...</div>
I need to extract the array assigned to DATA-mylist and assign it to a property as in:
$('#somediv').mywidget({
prop1 : 45, //For example
arr_prop : $('#mydiv').data('mylist')
});
Here arr_prop expects an array. It is not getting one. I get the following error:
Uncaught TypeError: Cannot use 'in' operator to search for '12' in [ [0,0], ..
I tried a few things to get it to work, other than using the .attr() method instead of .data() which I think is not the right approach anyway. I am possibly missing something very basic somewhere. Please help!
mywidgetthedatapart works fine jsfiddle.net/28Kzh