Skip to content
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

on change event is not triggering on dropdown change #3352

Open
balukantu143 opened this issue Dec 8, 2020 · 2 comments
Open

on change event is not triggering on dropdown change #3352

balukantu143 opened this issue Dec 8, 2020 · 2 comments

Comments

@balukantu143
Copy link

I have a dropdown and with few values and to call a method on dropdown value change. on changing the dropdown value, the function is not invoking.
I am unable to figure out the exact issue. Below is the code and let me know are there any errors.

`

    private wireup(): void {
    this.view.on("invokeDorpdownChange", () => this.invokeDorpdownChange());
}

invokeDorpdownChange(): any {
    // Logic
}


<div >
	<select on-change="invokeDorpdownChange">
		<option value="1" selected="selected">Today</option>
		<option value="2">Tomorrow</option>
		<option value="3">This week</option>
		<option value="4">This month</option>
		<option value="5">Next month</option>
	</select>
</div>`
@giovannipiller
Copy link
Contributor

giovannipiller commented Dec 8, 2020

It's quite difficult to help you out with so little info. There's nothing obviously wrong in your code excerpt, though it could be something as simple as a typo (ex. Dorpdown vs. Dropdown).
We have no idea of where your "wireup" function is called or how your components are set up.

Could you build a fiddle (ex. using jsfiddle) with enough code to reproduce the issue?
You can use this as a starting point: https://jsfiddle.net/nzt7hkba/2/ (I've copied some of your code there)

What version of Ractive are you using?
Which browser are you using?

@evs-chris
Copy link
Contributor

As an aside, there's no need to have an event fire to call a method on the ractive instance. You can call it directly from the event listener in the template with @this or its alias @ e.g. <select on-change="@.invokeDropdownChange()">.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants