Using jQuery, I am trying to find all elements with a data-inject
attribute from an HTML string returned from the server. Here's an example HTML string:
var html = '<div class="container-fluid">
<div class="row-fluid">
<div data-inject="ViewModel1" class="span12"></div>
</div>
</div>
<div data-inject="ViewModel2" class="navbar navbar-fixed-bottom"></div>';
I can't seem to find a way to get both div
s and the problem seems to be the fact that I'm starting with a HTML string.
Here's a fiddle showing that just querying the DOM with $('[data-inject]')
returns the two elements as expected. However, querying the HTML string with $('[data-inject]', html)
only returns one element (the ViewModel1
element).
Anyone know what I'm doing wrong and how to get the expected result?