Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <a href="javascript:;" class="<?php if($value['collapsed']=='yes') echo 'expand'; else echo 'collapse';?>" onclick="constructAjaxTree('<?php echo $value['_id']?>','<?php echo $value['code']?>');"></a>
- function constructAjaxTree(aspectid,aspectcode)
- {
- if ($('.tag_input').find('.tag').length)
- {
- var elements = [];
- //iterates through each input field and pushes the name to the array
- $(".tag_input").children(".tag").each(function() {
- var id = $(this).attr("id");
- elements.push(id);
- });
- var geographylevel='';
- $.post('include/ajax.php', {option: 'checkavailabilitylevel', geography: elements}, function(response){
- geographylevel=response;
- $("#"+"div_"+aspectid).jstree({
- "xml_data" : {
- "ajax" : {
- "url" : "include/ajax.php?option=constructtree",
- "data" : function (n) {
- return { aspectcode : aspectcode, geographylevel : geographylevel };
- }
- },
- "xsl" : "nest"
- },
- "plugins" : [ "themes", "xml_data","ui","checkbox","cookies" ],
- "checkbox":{"override_ui":true}
- }).bind("check_node.jstree", function (event, data) {
- // `data.rslt.obj` is the jquery extended node that was clicked
- var nodeid= data.rslt.obj.attr("id");
- addAspect(nodeid);
- });
- $("#"+"div_"+aspectid).bind("uncheck_node.jstree", function (event, data) {
- // `data.rslt.obj` is the jquery extended node that was clicked
- var nodeid=data.rslt.obj.attr("id");
- removeAspect(nodeid);
- });
- $('#'+'div_'+aspectid).delegate(".jstree-open>a", "click.jstree", function(event){
- $.jstree._reference(this).close_node(this,false,false);
- }).delegate(".jstree-closed>a", "click.jstree", function(event){
- $.jstree._reference(this).open_node(this,false,false);$('#')
- });
- });
- }
- else
- {
- alert("Please Select Geography First");
- }
- }
- if($_REQUEST['option']=='constructtree')
- {
- $splittedaspectcode=explode("~",$_REQUEST['aspectcode']);
- $xmlDoc = new DOMDocument();
- $xmlDoc->preserveWhiteSpace = false;
- $xmlDoc->load("../aspect.xml");
- $xpath = new DOMXPath($xmlDoc);
- $query = "//item[@id='".$splittedaspectcode[0]."']";
- $nodeList = $xpath->query($query);
- $newDom = new DOMDocument('1.0','UTF-8');
- $root = $newDom->createElement('root');
- $root = $newDom->appendChild($root);
- foreach ($nodeList as $domElement){
- $domNode = $newDom->importNode($domElement, true);
- $root->appendChild($domNode);
- }
- //$newDom->save("test.xml");
- echo $newDom->saveXML();
- //constructTree($db,$_REQUEST['aspectcode'],$_REQUEST['geographylevel']);
- }
- <root>
- <item id="3" level="1" availabilitylevel="6" >
- <content><name><![CDATA[Households]]></name></content>
- <item id="3.1" level="2" availabilitylevel="6" class="node">
- <content><name><![CDATA[All Households]]></name></content>
- <item id="3.1.1" level="3" availabilitylevel="6">
- <content><name><![CDATA[Urban]]></name></content>
- </item>
- <item id="3.1.2" level="3" availabilitylevel="6">
- <content><name><![CDATA[Rural]]></name></content>
- </item>
- </item>
- </item>
- </root>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement