papas
12-09-2009, 09:12 PM
function checkifischild(draggedElement,destination)
{
$getid = $("#" + destination).attr("class");
var __temp = $getid.split(' ');
console.log(__temp)
for(i = 0;i < __temp.length; i++){//for the length of the classes
if(__temp[i].match("child-of-"))
{//check if its a child
parent = __temp[i].substring(9);//get the parents node
if(draggedElement == parent)
{
console.log('yes');
return false;
}
}
}
checkifischild(draggedElement,parent)
}
i have the following function
basically what it does it gets 2 parameters
node-23,node-17 for example
it finds the classes of node-17 and splits them up
["child-of-node-16", "initialized", "ui-droppable", "expanded"]
["child-of-node-19", "initialized", "parent", "expanded", "ui-droppable"]
["child-of-node-23", "initialized", "parent", "expanded", "ui-droppable"]
so i compare each time the first parameter along with the substring of the child-of and if they are the same its returns false
now my problem is if i call the function just like this
checkifischild(node-23,node-17) it works i get in the console yes for example
if i do this tho if(checkifischild(node-23,node-17) == false) it fails :?
any ideas will be appreciated thxxx
{
$getid = $("#" + destination).attr("class");
var __temp = $getid.split(' ');
console.log(__temp)
for(i = 0;i < __temp.length; i++){//for the length of the classes
if(__temp[i].match("child-of-"))
{//check if its a child
parent = __temp[i].substring(9);//get the parents node
if(draggedElement == parent)
{
console.log('yes');
return false;
}
}
}
checkifischild(draggedElement,parent)
}
i have the following function
basically what it does it gets 2 parameters
node-23,node-17 for example
it finds the classes of node-17 and splits them up
["child-of-node-16", "initialized", "ui-droppable", "expanded"]
["child-of-node-19", "initialized", "parent", "expanded", "ui-droppable"]
["child-of-node-23", "initialized", "parent", "expanded", "ui-droppable"]
so i compare each time the first parameter along with the substring of the child-of and if they are the same its returns false
now my problem is if i call the function just like this
checkifischild(node-23,node-17) it works i get in the console yes for example
if i do this tho if(checkifischild(node-23,node-17) == false) it fails :?
any ideas will be appreciated thxxx