Coder Social home page Coder Social logo

Comments (2)

neuronetio avatar neuronetio commented on July 1, 2024

Events are not binded to Events c'mon ;) but this inside function in option events for sure are not pointing to your containing component.
This is intended behavior - this is up to you what you bind to your events - you can also use scoped variable in your function to get your component data.
gantt-elastic does not want to know anything about parent component - it should be kind of sandboxed and self contained thing.
I don't know how you mount gantt (as standalone component? as component in other component?) so I can't really help - more code is needed to help.
I suggest to mount via app = new Vue(....) option, so app will contain all your data, and then inside click handler you can use app.lastId data property.

let app;
const tasks ={/*...*/};
const options = {
/*...*/
click({event, data}){
    // app is assigned here for sure because no click event will be fired before vue initialisation,
    // after vue is mounted and start working, click event will be fired, and after vue is mounted app is assigned
    app.lastId++;
}
/*...*/
};
app = new Vue({
  el:'#gantt',
  template:`<gantt-elastic :tasks="tasks" :options="options"></gantt-elastic>`,
  components: {
    ganttElastic: GanttElastic
  },
  data() {
    return {
      tasks: tasks,
      options: options,
      lastId:16,
    };
  }
});

from gantt-elastic.

neuronetio avatar neuronetio commented on July 1, 2024

You can also define function before and bind it to your app (javascript is really elastic and I like it for this :) ).

let app; // for now let it be here and wait for assignment
function myClickHandlerBluePrint({event, data}){
  this.lastId++;
}
const myClickHandler = myClickHandlerBluePrint.bind(app);
const options = {
/* ... */
  click: myClickHandler, // WHAAAAAT :O ?
/* ... */
};
app = new Vue({  // let assign vue instance to app variable
/* ... */
data(){
  return {
    tasks,
    options,
    lastId:16,
  };
}
/* ... */
})

from gantt-elastic.

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.