tcnarss
tcnarss

Reputation: 595

Removing XML data based on divs being hidden using jQuery

Okay this is quite complicated to explain but i'll try and keep it as short as possible. I'm making an 'app', part of the function of which is to pull XML based data from a file using PHP DOMDocument() and a loop to display each block of information in its own DIV. My aim is to allow the user to then click a 'close' button on any of these displayed div's and they will be hidden using jQuery similar to this:

$('input[name=foo]').live('change', function(){
     if ( $(this).is(":checked")) {
         $('.bar').hide(500);
     } 

I'm pretty certain I can get it up to this stage with no issues however, when the user saves at the end of this process I want to pass params back that relate to the boxes that have been hidden/removed using $_POST and then subsequently remove the corresponding items/nodes from the original xml document. Each item and each close button has a unique ID.

Any tips on how to achieve this would be much appreicated. thanks

Upvotes: 0

Views: 122

Answers (3)

lovesh
lovesh

Reputation: 5411

just get the ids or names of the div that have hidden and send that as POST and then go to their parent element. suppose their parent node is referenced in $parent and the node u want to remove is referenced in $child. Now use $parent->removeChild($child)

or u can do this get the node reference say $node then use

$node->parentNode->removeChild($node);

Upvotes: 1

Robert de W
Robert de W

Reputation: 306

When one of the boxes is clicked, do a xmlhttprequest using the post method.

$.post() pasing the ID and state of the box.

Upvotes: 0

Mrchief
Mrchief

Reputation: 76258

One idea is that you can check whether the div is hidden or not like $(".bar").is(':hidden'); and then not include it in the XML you're sending back.

Upvotes: 0

Related Questions