Html5 data attributes containing boolean
In our DEVELOPMENT environment, we have used HTML5 data attributes to store boolean values (I now know this is not the way to go). For example:
<div id="x" data-mydata="True"></div>
And then in our JS code (using jQuery) we have successfully matched the boolean:
var v = $('#x').data().mydata;
if(v == 'True') {...}
And it worked great - and equally for False values.
However, when we pushed this to our QA environment, it stopped working. Although we set the value to "True", the value the jQuery selector reads was "data-mydata" (data attribute name).
As mentioned above, we looked at the correct way to handle booleans (if the value is false, then exclude the data attribute).
But, my question is, why did this work one thing (wrong) in our Dev environment? We are using the same version of jQuery, and as far as I checked, the DLLs are the same version.
FYI is our IDE currently: VS2010, ASP.NET MVC4.NET 4.0.
thank
Griff
source to share