How do I use custom triggers?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tothewine
    Active Community Member
    • Jan 2018
    • 376

    How do I use custom triggers?

    I am adding a custom button to a view (in /modals/duplicate.js) and would like to trigger a custom event to be handled by the parent code (/record/detail.js) that subscribes to it.

    In my button's click handler I do this:
    Code:
    this.trigger('customEvent');
    In the parent view I did
    Code:
    [FONT=courier new]this.listenToOnce(view, 'customEvent', function () {/*... code ... */}[/FONT]
    But it did not work. Is there some documentation I am missing?
  • eymen-elkum
    Active Community Member
    • Nov 2014
    • 472

    #2
    Make sure that view is defined
    and u can try
    view.on('customEvent',function(){/*... code ... */} )
    CEO of Eblasoft
    EspoCRM Expert since 2014
    Full Stack Web Developer since 2008
    Creator of Numerous Successful Extensions & Projects​

    Comment

    • tothewine
      Active Community Member
      • Jan 2018
      • 376

      #3
      Thanks, the view is defined since I was just adding to espo's original code in record/detail.js. I will try the "view.on()" method.

      Comment

      Working...