I`m creating a binding with knockout...see the code
ko.bindingHandlers.fadeVisible = {
init: function(element, valueAccessor) {
// Start visible/invisible according to initial value
var shouldDisplay = valueAccessor();
$(element).toggle(shouldDisplay);
// Handle mouse events on the stars
},
update: function(element, valueAccessor) {
// On update, fade in/out
var shouldDisplay = valueAccessor();
shouldDisplay ? $(element).fadeIn() : $(element).fadeOut();
}
};
... something seems to be wrong with the fadeOut()
function on the last line: the Editor alerts:
"expected an assignment or function call and instead saw expression"
I´ve no idea why, since fadeOut()
is obviously a function...
Try using
ko.unwrap(shouldDisplay)
on each of your shouldDisplay variables.
The message is from JSLint/JSHist and you can ignore it.
See http://jslinterrors.com/expected-an-assignment-or-function-call
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.