I use this code to collect data() but its not working in chrome because it come in reversed order, how can I make the result match.
This is the same code. I just get different resutls across chrome/firefox which make it not functioning in chrome.
/* get checked filters */
strJson = '{';
jQuery('.uag-filter-option').each( function() {
if (jQuery(this).hasClass('checked')) {
jQuery.each(jQuery(this).data(), function(i, v) {
strJson += i + ":'" + v + "',";
});
}
});
strJson = strJson.slice(0, -1);
strJson += '}';
alert(strJson);
In FireFox I get:
{sort:\'sortbydate\',method:\'sortby\'}
in Chrome I get:
{method:\'sortby\',sort:\'sortbydate\'}
How can I get the same result in Chrome as in Firefox? I assume it is how the data() was handled in different browsers?
Here is the anchor containing the data:
<a href="#" class="uag-filter-option" data-method="sortby" data-sort="sortbydate">date</a>
Any thoughts please?
It seems that:
When accessing data attribues using jQuery.data(), the order of them is reversed in Firefox and IE. How to come around that to make it match in all browsers?