Reputation: 8977
Using:
$(event.currentTarget).fadeTo(0, 1);
Seems to work, while using:
$('.btn .active').fadeTo(0, 1);
Does not. Any idea why?
jsFiddle link here: http://jsfiddle.net/SeanKilleen/fwerK/
JavasScript code below:
var global_loggedOnUser = "User1";
$(document).ready(function () {
var viewmodel = (function () {
this.feedbacktype = ko.observable("None");
this.currentPage = ko.observable(location.href);
this.currentUsername = global_loggedOnUser;
this.updateFeedbackType = function (item, event) {
var newText = $(event.currentTarget).children("span").text();
$('#buttonList button').removeClass('active');
$(event.currentTarget).addClass('active');
feedbacktype(newText);
$('.btn').not('.active').fadeTo('fast', 0.3);
$('.btn .active').fadeTo('fast', 1);
};
return {
pageUserIsOn: currentPage,
theUser: currentUsername,
feedbackType: feedbacktype
};
})();
ko.applyBindings(viewmodel);
});
I'm trying to accomplish this by adding an "active" class to the button and removing it from all others, and then performing the fade based on class.
What am I missing?
Upvotes: 1
Views: 1232
Reputation: 54629
Remove the space between the classes, you want to select elements with both classes not .active
descendants of .btn
$('.btn .active').fadeTo('fast', 1);
should be
$('.btn.active').fadeTo('fast', 1);
Upvotes: 2