hello as I add and remove a class by making click on a row.
Template.offerRooms.events({
‘click .room-tbody tr’: function(event){
event.preventDefault();
$(event.target).addClass(‘selected’);
},
‘click .selected’: function(event){
console.log(“se quita”);
$(event.target).removeClass(“selected”);
}
helfer
April 26, 2016, 6:46pm
2
It’s very hard to figure out what you’re trying to say. Can you try to rephrase the question?
sure, what I try to do is that when you click in a row a class is added to td, but if I click again the class is removed.
thanks for your help and forgive the language
1 Like
hello, solve it so
‘click .room-tbody tr td’: function(event){
event.preventDefault();
if ($(event.target).hasClass(“reserved”)) {
console.log(“esta esta registrada”);
} else if($(event.target).hasClass(“selected”)) {
$(event.target).removeClass(‘selected’);
} else {$(event.target).addClass(‘selected’); }
}
helfer
April 26, 2016, 8:17pm
5
Ok, glad you figured it out!
cstrat
April 27, 2016, 4:01am
6
I dont think you need the event.preventDefault();
because you’re just working on a click event on a table cell.
You only need prevent default when there is some default browser behaviour you want to prevent, like on a form submission or a anchor/URL click…