Giter Club home page Giter Club logo

Comments (4)

jtrussell avatar jtrussell commented on July 30, 2024

You can be alerted of the click event by changing the ivhTreeviewOptionsProvider to change the leaf twistie template. Here's an example.

Currently there's no documented way to get at which item was clicked (in my example I point out a workaround if you truly need it). We plan to give proper hooks in the future (registering callbacks, directive stubs, etc.) so I wouldn't expect that capability to go away but the specific supported mechanism for figuring out which item was clicked may change.

from angular-ivh-treeview.

18601673727 avatar 18601673727 commented on July 30, 2024

Yes, I really need it, because I have to grab some data from a third party API asynchronously.
The solution in your example is terrific, but here's further question according to this one:

app.directive('leaf', function() {
  return {
    restrict: 'AE',
    link: function(scope, element, attrs) {
      element.on('click', function() {
        alert('OHAI');
        // It's not ducmented and may change but if you **really**
        // need it scope.node is available:

        // Sure, I won't ask for help without reasons :)     
        // For example, when API returned a new Array, 
        // How to add it to the tree dynamically?
        // I tried this one but nothing happened.
        scope.node.children = [{
          label: 'IComeFromApi',
          children: []
        }];

        // ```
        console.log(scope.node);
        // ```
      });
    }
  };
});

from angular-ivh-treeview.

jtrussell avatar jtrussell commented on July 30, 2024

Ah, unfortunately we aren't set up to handle dynamic changes to the tree. I'd encourage you to open a new issue for the feature though.

At present the best you could do is manually force a recompile on the tree or part of it. Here's a hacked together demo using ng-if. Obviously this is far less than desirable for a number of reasons. A true solution would probably involve setting up watchers in ivh-treeview-node and just recompiling that branch when something changes.

from angular-ivh-treeview.

18601673727 avatar 18601673727 commented on July 30, 2024

My boss'll be happy next week, your temporary solution works fine but not perfect as you said, thanks so much for everything 👍

from angular-ivh-treeview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.