It is possible I am making some javascript mistakes here.
I am using a following (sample)code to add options to a drop-down list:
sel = document.getElementById("emp-list");
<for loop> (
opt = document.createElement('option');
//add value to option also add a 'assiganble' data
var assign = true;
opt.setAttribute("data-assignable", assign);
sel.appendChild(opt);
)
Now, when user select an option, I have a function that first check for 'assignable' condition.
if ($("#emp-list option:selected").data('assignable')) {
} else {
}
in one machine this works as expected ... it correctly evaluates if condition as Boolean true/false and proceed with rest of the code.
However, in a second machine it always executes 'false' block!! So far, only way to work this in second machine is to use following if condition:
if ($("#emp-list option:selected").attr('data-assignable') === "true") {
} else {
}
(if I don't use === "true" , true block is always executed; even-though i was expecting .attr('data-assignable') as boolean)
Can you explain why this behavior?