2

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.

1
  • 2
    What is the value of partialViewHtml? If it's '<div class="window-details" data-height="500px" data-width="500px">more data here</div>', then there is no child of that HTML with class window-details, which is what you're trying to select. Commented Sep 10, 2012 at 14:47

2 Answers 2

2

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");
Sign up to request clarification or add additional context in comments.

Comments

0

Your code searches for elements with the .window-details in the children of the div that was returned.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.