New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to load children of node from http request #462
Comments
Do you mean that you are using the lazy loading option? Also see this example. |
Yes, I'm using the lazy loading option. You example only shows how to load the first level and it's children, I've got that. But I also want to select one of the children and show it's children. |
I forgot to mention, so in my above example, the http request might be |
If i understand correctly, you want to:
Please tell me if this is correct. |
Yes..that is correct Regards, Jim Mashore Jim Mashore | 405.990.0118 | jmashore@adsnm.com | J.IM.MOTU All information in this Communication, including attachments, is strictly confidential and intended solely for delivery to and authorized use by the addressee(s) identified above, and may contain privileged, confidential, proprietary and/or trade secret information entitled to protection and/or exempt from disclosure under applicable law. If you are not the intended recipient, please take notice that any use, distribution or copying of this Communication, and/or any action taken or omitted to be taken in reliance upon it, is unauthorized and may be unlawful. If you have received this Communication in error, please notify the sender and delete this Communication from your computer. From: Marco Braak [mailto:notifications@github.com] If i understand correctly, you want to:
Please tell me if this is correct. — |
That's an interesting problem. If you call the openNode function, then that will load its children if necessary. So, perhaps I can add a callback to If that is added, then your code could look something like this: var belts_node = $tree.tree('getNodeByName', 'Baler belts');
$tree.tree(
'openNode',
belts_node,
function() {
// node is opened; its children are loaded
var challenger_node = $tree.tree('getNodeByName', 'Challenger');
$tree.tree('openNode', challenger);
}
); Do you think this would work in your situation? |
I think that would work in my problem yes. I suppose if someone wanted to iterate down through more than just two nodes, they have the ability to do also. Like you said, the callback is the important thing when using the lazy loader the tree has to be aware of the node before it can open it. Regards, Jim Mashore Jim Mashore | 405.990.0118 | jmashore@adsnm.com | J.IM.MOTU All information in this Communication, including attachments, is strictly confidential and intended solely for delivery to and authorized use by the addressee(s) identified above, and may contain privileged, confidential, proprietary and/or trade secret information entitled to protection and/or exempt from disclosure under applicable law. If you are not the intended recipient, please take notice that any use, distribution or copying of this Communication, and/or any action taken or omitted to be taken in reliance upon it, is unauthorized and may be unlawful. If you have received this Communication in error, please notify the sender and delete this Communication from your computer. From: Marco Braak [mailto:notifications@github.com] That's an interesting problem. If you call the openNode https://mbraak.github.io/jqTree/#functions-opennode function, then that will load its children if necessary. So, perhaps I can add a callback to openNode that is called when the node is opened (and its children are loaded). If that is added, then your code could look something like this: var belts_node = $tree.tree('getNodeByName', 'Baler belts'); $tree.tree(
} Do you think this would work in your situation? — |
I added the As stated in the comment above you can use it as follows: function handleOpenNode(node) {
console.log('openened', node);
}
$tree.tree('openNode', node1, handleOpenNode); If you want to configure the sliding animation, then // turn sliding animation off
$tree.tree('openNode', node1, false, handleOpenNode); Thank you for suggesting this feature. I think it is really useful. Please let me know if it works. Cheers, |
Marco.. Thanks so much for doing this. I’ll pull down the Dev branch and test it as soon as I can. Once again thanks for being so responsive ! Regards, Jim Mashore Jim Mashore | 405.990.0118 | jmashore@adsnm.com | J.IM.MOTU All information in this Communication, including attachments, is strictly confidential and intended solely for delivery to and authorized use by the addressee(s) identified above, and may contain privileged, confidential, proprietary and/or trade secret information entitled to protection and/or exempt from disclosure under applicable law. If you are not the intended recipient, please take notice that any use, distribution or copying of this Communication, and/or any action taken or omitted to be taken in reliance upon it, is unauthorized and may be unlawful. If you have received this Communication in error, please notify the sender and delete this Communication from your computer. From: Marco Braak [mailto:notifications@github.com] I added the on_finished callback to the openNode function. It's in the dev branch. As stated in the comment above you can use it as follows: function handleOpenNode(node) { $tree.tree('openNode', node1, handleOpenNode); If you want to configure the sliding animation, then sliding is the second parameter, and on_finished the third: // turn sliding animation off Thank you for suggesting this feature. I think it is really useful. Please let me know if it works. Cheers, — |
Marco: I downloaded the latest Dev Branch code but it doesn’t appear the callback is executing.. I’m not getting the “Node is open executing callback…” message at all belts.node is populated so I know it’s doing that right.. It’s children show Challenger at index 6 in the children array so that’s there. I redownloaded the dev branch again just to be sure I had it right. But still didn’t work. $(document).ready(function () {
}); var menuTree = $('#tree1'); function loadTree() { data = [{"id": "ET21", "label": "Baler Belts", "load_on_demand": true}];
} From: Marco Braak [mailto:notifications@github.com] I added the on_finished callback to the openNode function. It's in the dev branch. As stated in the comment above you can use it as follows: function handleOpenNode(node) { $tree.tree('openNode', node1, handleOpenNode); If you want to configure the sliding animation, then sliding is the second parameter, and on_finished the third: // turn sliding animation off Thank you for suggesting this feature. I think it is really useful. Please let me know if it works. Cheers, — |
I forgot to compile the javascript code. This is now done; the latest changes are in |
Marco: I downloaded the dev branch again and just made a clean install. Still no luck. I shows me getting the parent node (baler_belt) But the console log in the call back never shows… var belts_node = menuTree.tree('getNodeByName', 'Baler Belts'); menuTree.tree(
From: Marco Braak [mailto:notifications@github.com] I forgot to compile the javascript code. This is now done; the latest changes are in tree.jquery.js. — |
What version of jquery should I be using. I think I’m loading 1.11.1 on this project, it’s kinda old. From: Marco Braak [mailto:notifications@github.com] I forgot to compile the javascript code. This is now done; the latest changes are in tree.jquery.js. — |
It should work on jquery 1.11.1 |
Let's check if you have the correct Can you find the string |
Yeah…I see it there…Ok..I’ll try it in a simpler environment. From: Marco Braak [mailto:notifications@github.com] Let's check if you have the correct tree.jquery.js. Can you find the string on_finished_param in the file? If so, then it's the correct version. — |
Marco: I found the issue. If in our Example the tree loads initially with the Baler Belts node already open, then the callback is never executed. If I just load Baler Belts but keep it closed (unpopulated) then the call back to open node “Challenger” executes. This becomes an issue of your also saving the state of the tree so that when they come back to the page the tree is in it’s last used state. I haven’t fully tested it yet, but I just thought I’d let you know. From: Marco Braak [mailto:notifications@github.com] Let's check if you have the correct tree.jquery.js. Can you find the string on_finished_param in the file? If so, then it's the correct version. — |
Yes. I think this is difficult to combine with 'save_state' option. Perhaps it's better to not use 'save state' in this particular situation. |
Not really a bug...
I have a lazy loader tree. It starts with three top nodes (Nodes 19,20,21). I can show the top node I have some code that checks the http request for what top node they want and automatically shows it and it's children (Nodes 81,82,83)
But I want to be able to select (via javascript) the top node (node 19) and it's direct child (node 81) and display the parts associated with (node 81) - (nodes 101,102 ,103).
I know what nodes I want, I just can't figure out to get to them beyond the top node.
|-Manufacturer 1A (node 81)
|-Part 1Aa (node 101)
|-Part 1Ab (node 102)
|-Part 1Ac (node 103)
|-Manufacturer 1B (node 82)
|-Manufacturer 1C (node 83)
The text was updated successfully, but these errors were encountered: