-
Notifications
You must be signed in to change notification settings - Fork 89
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
onToggle not fired for leaf nodes #169
Comments
@what's the use case for toggling a leaf node? Having no child nodes they cannot be expanded or collapsed. Are you really interested in just having a click callback for labels? Or perhaps you're looking to load child additional child nodes dynamically? |
I have several treeviews that are basically a single selection tree that drives a subview. I have the current selection highlighted when the user clicks on a node. |
Note, I'm using 'useCheckboxes=false' |
Is there a way to have a click callback for labels? I too want to have a single selection tree. I think a click callback on labels would make that possible. |
Hi @charles-henry , I'm also looking for this functionality, I think it makes sense to be able to do that. Have you figure it out yet? Or maybe @cgatesman ? |
@arielcr, I just patched my local copy of ivh-treeview.js with the code I have above in the |
@jtrussell Why not to provide option for leaf select with callback as @cgatesman asked. You will update the directive or we should do this feature manually? |
This was not implemented simply because leaf nodes cannot be expanded or collapsed by their nature :). If you'd like generic click handlers perhaps you could just use |
@jtrussell I will give you an example of this need, e,g, I need on leaf,parent,root clicks filter my page. For this aim I need any id of the clicked item. In current code I can get id |
Can you accomplish this with a little directive attached to each node in your template? Something like this (untested): app.directive('onNodeClick', function() {
return {
link: function(scope, element) {
element.on('click', function() {
scope.$emit('NODE_CLICK', scope.node);
scope.$apply();
})
}
};
}); |
Something like you solution I had been implemented. However, in my opinion, such functionality is good feature to have. :) |
I'd be open to adding such a feature with if a PR came in with tests :). That said have you tried using the v2 branch? In that version you'll have access to your transcluded scope when using inline templates: <div ivh-treeview="fancy.bag">
<script type="text/ng-template">
<div>
<span ng-click=" ng-click="otherCtrl.clicky(node)">
{{trvw.label(node)}}
</span>
<div ivh-treeview-children></div>
</div>
</script>
</div> Where |
I used v2.0.0-alpha.3. |
Hi @jtrussell I'm using v2 of treeview.js but I can't reach controller's function as your post says. Other controller is not fancy controller? maybe there is something that I'm missing. |
I would like to "select" leaf nodes using
useCheckboxes="false"
. Currently onToggle is not getting called for leaf nodes. To me, it seems like it should. The handler should be the one responsible for dealing if it's a leaf or not--if that really matters.Something more like this in
ivhTreeviewToggle
:The text was updated successfully, but these errors were encountered: