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

onSelect event doesn't work at all #41

Open
vahidvdn opened this issue Jul 8, 2019 · 2 comments
Open

onSelect event doesn't work at all #41

vahidvdn opened this issue Jul 8, 2019 · 2 comments

Comments

@vahidvdn
Copy link

vahidvdn commented Jul 8, 2019

Here is my code:

$('#options').flagStrap({
        countries: {
            "AU": "Australia",
            "GB": "United Kingdom",
            "US": "United States"
        },
        inputName: 'country',
        buttonSize: "btn-lg",
        buttonType: "btn-primary",
        labelMargin: "20px",
        scrollable: false,
        scrollableHeight: "350px",
        onSelect: function(value, element) {
          // doesn't work
          console.log('select!!');
        },
        placeholder: {
            value: "",
            text: "Please select a country"
        }
    });

But the onSelect event never get fired. Any idea?

@vahidvdn
Copy link
Author

vahidvdn commented Jul 8, 2019

I found a hacky way, but it's not a good idea:

$("body").on('DOMSubtreeModified', ".dropdown-toggle span", function(e, data) {
    console.log(e.target.innerText);
});

@Servibe
Copy link

Servibe commented Nov 16, 2023

Another possibility is to add a specific click event on the items.

$('#idioma .dropdown-menu li a').click(function (e) {
    e.preventDefault();

    console.log($(this).data('bsVal'));
  });

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

2 participants