0

In response to clicking the "ALL" checkbox, I need to change multiple checkboxes. The changes include changing the class, checked state and some hidden fields. Instead of changing each attribute individually in javascript, to ensure consistency, I am returning the partial views of all affected checkboxes. My goal is to parse the returned string in javascript and place each div in the appropriate location using JQuery's .html() method. The returned string looks as follows

"<div id="checkbox-7" class="simple"><form action="toggle" ...></form></div>
 <div id="checkbox-8" class="simple"><form action="toggle" ...></form></div>
 ...
 <div id="checkbox-all" class="simple"><form action="toggle" ...></form></div>"

How can I extract each div from this string using Javascript/ jQuery?

Manish
  • 1,726
  • 3
  • 23
  • 29
  • Your Question is Not very Clear..For seeking Help ..Help members to understand your Need ..at some Fiddle ..some snapshot..etc – Shekhar Pankaj May 24 '14 at 22:53

1 Answers1

0

The DOM manipulation in this question suggested a solution by creating a Javascript document object to facilitate parsing. There is some co-mingling of Javascript and jQuery though:

var placeholderDoc = document;
var placeholderDiv = placeholderDoc.createElement("div");
$(placeholderDiv).html(data);     // data is the returned string, containing all partialViews

// Now extract partialView from the data string
var extractedHtml = $(placeholderDiv)[0].children["tdCellHtmlDivId"];

// Simulate the Ajax InsertionModeReplace
tdCellHtmlDivParentDiv.html(extractedHtml);
Community
  • 1
  • 1
Manish
  • 1,726
  • 3
  • 23
  • 29