Parsing and selecting from HTML string
Using an ajax call I have returned the partialView HTML of a page, but before I display it I wish to pull information from the main div. This data is just size information, for if I create a floating window.
Code:
<div class="window-details" data-height="500px" data-width="500px">more data here</div> this.PopUp = function (url, title) { $.ajax(url) .success(function (partialViewHtml) { var partialViewDom = $(partialViewHtml); var thisDiv = $(".window-details", partialViewDom);
I can see the data in chromes debugger when hovering over partialViewDom, but the class selection does not appear to have worked. Any clues? Does it not parse correctly? Thanks.
Answers
Try using the .filter() instead, most likely your .window-details element is a top level element in the dom fragment.
var thisDiv = partialViewDom.filter(".window-details");