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

How to use "events" #47

Closed
nivv opened this issue Jun 1, 2016 · 3 comments
Closed

How to use "events" #47

nivv opened this issue Jun 1, 2016 · 3 comments
Labels

Comments

@nivv
Copy link

nivv commented Jun 1, 2016

Thanks for a great looking component package!

I'm trying to catch an event but I'm not sure how to do it. The @option-selected triggers, but how can I get the data from the event?

<ui-menu color="primary"
    @option-selected="doStuff()"
    :show-secondary-text="true"
    :options="[{text: 'Hey', id: 1, 'secondaryText': 'Ok whatever'}, {text: 'foop', id: 2}]">
    Hello world!
</ui-menu>
export default {
    name: 'Home',
    ready: function() {
        this.$on('option-selected', function (msg) {
            console.log(msg)
        })
    },
    methods: {
        doStuff: function() {
            //How do I get the option data here?
        }
    }
}
@JosephusPaye
Copy link
Owner

Hi @nivv,

You just need to pass a method name and it will be called with the selected option. Notice it is doStuff and not doStuff(). The second strips the argument.

Try the following and it should call doStuff with the selected option:

<ui-menu
    :options="[{ text: 'Help', id: 1 }, { text: 'About', id: 2 }]"
    @option-selected="doStuff"
></ui-menu>
export default {
    name: 'Home',

    methods: {
        doStuff: function(selectedOption) {
             console.log('Selected', selectedOption);
        }
    }
}

@nivv
Copy link
Author

nivv commented Jun 1, 2016

Cool! Thanks!

@leinue
Copy link

leinue commented Jul 4, 2016

thanks,got what i wanted

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

No branches or pull requests

3 participants