How to use onchange event in hbs file ?

Hi There, 

I have two drop down list in hbs template.  I have to show the 2nd drop down options based on selection of 1st drop down. For ex: my 1st drop down is state and 2nd is city, On selection of state , city dropdown options should list based on the state we selected. 

I have no idea how to use onchange menthod in hbs file. Anyone please suggest me any way ? 

Parents
  • you need to add the onclick event listener on the js file . not in the HBS file. For instance if you have a custom dashlet you would have dashlet.js that contains a list of events:

    events : {
    		"click a[data-event='do:stuff']" : "doSomeStuff",
    	},

    In this case I added a listener to a link (<a href..) that has an attribute data-event with the value do:stuff. Next you need to implement the doSomeStuff function in that same controller. 

    On the HBS part you would add an attribute data-event="do:stuff" to you select tag. 

    Just be aware that you need to do a renderhtml or update the html another way yourself. 

Reply
  • you need to add the onclick event listener on the js file . not in the HBS file. For instance if you have a custom dashlet you would have dashlet.js that contains a list of events:

    events : {
    		"click a[data-event='do:stuff']" : "doSomeStuff",
    	},

    In this case I added a listener to a link (<a href..) that has an attribute data-event with the value do:stuff. Next you need to implement the doSomeStuff function in that same controller. 

    On the HBS part you would add an attribute data-event="do:stuff" to you select tag. 

    Just be aware that you need to do a renderhtml or update the html another way yourself. 

Children
No Data