Pergunta

        ui: {
        "feature": "a.mouse-event-f"
    },

    events: {
        "click @ui.feature": "select"
    },

    select: function() {
        this.ui.feature.find("div.item_number").addClass("item_number_green");
    },

There are several elements with class "mouse-event-f" and in my case the class "item_number_green" is being added to all of them. But I need to add this class only to the clicked element. Is it possible?

Foi útil?

Solução

The select function is passed an event parameter containing the target of the click event. You can use that parameter like this:

select: function( e ) {
    $(e.target).addClass("item_number_green");
},
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top