Ok, I have to say that it was a problem with karma, not jquery.
We use Backbone.js, and the view loads the template into the view definition:
template : _.template($("#mytemplate").html()),
Karma when loading tests will be an exception if it does not find devices, so we added lights to the file called fixtures.js at startup:
loadFixtures('viewtemplate.html','mytemplate.html');
(@Blame) Someone added a jasmine test suite to this code beforeEach :
beforeEach( function() { loadFixtures('currentStepContainerFixture.html', 'mytemplate.html');
Thus, the scales were loaded twice .
When I used in my code:
console.log($(this).attr('id') + " " + $(this).val()); console.log($(this).attr('id') + " " + $("#"+$(this).attr('id')).val());
Basically, the first log was about the current item, while the second log was about the first entry that has this identifier.
That is why we had this terrible behavior. I have to say that some kind of exception thrown for two elements with the same identifier would be helpful.
PhantomJS 1.6 (Linux): Executed 61 of 90 PhantomJS 1.6 (Linux) LOG: 'myId ' --> current $(this) PhantomJS 1.6 (Linux): Executed 61 of 90 PhantomJS 1.6 (Linux) LOG: 'myId 123' --> first occurrence of "#myId"
I do not deserve these four points, the problem was between the monitor and the keyboard. Excuse me: (