I'm relatively new to Knockout.js and I'm having trouble doing this calculable job. In short, I would like to disable a button until the tapetera is input. For Textarea:
& lt; Textarea class = "form-control" id = "note" name = "note" data-bind = "value: text1, value update: 'keyboard' placeholder =" note ... "& gt; & lt ; / Textarea> For
button:
Note Save & lt; / btn & gt;
And here is my .js:
var vm = {text1: k.a. ("") ,} Vm.hasInput = ko.computed (function () {return.text1 ();}, vm); ko.applyBindings (VM);
Run in firebugs Yes, I get an error from the console which reads:
Reference: Error: Lesson 1 is not defined
I should add that I can add my code To make this reference, I am referring to:
Edit: "click: addNote" part of the button was for something else I forgot to delete it in this snippet because "addNote" functionality Just working fine. I am sorry for the illusion and I thank you for seeing it all. Because of this, it seems that T.J. My question has been answered, I was working improperly within the binding view modal and the struggle was being fought due to binding.
I think you see an old error message with your VM as shown in your question The problem is that you do not have If you add it and make your < Div class = "snippet" data-lang = "JS" data-hide = "wrong"> addNote
defined anywhere, but you are trying to force it to click on .
BTN
element an actual button
, then all is well:
var vm = {text1: to .observable (""),}; Vm.hasInput = ko.computed (function () {return.text1 ();}, vm); Vm.addNote = function () {}; // & lt; === Added ko.applyBindings (vm);
& lt; Textarea class = "form-control" id = "note" name = "note" data-bound = "value: text1, value update: 'keep'" placeholder = "Enter note ..." & gt; & Lt; / Textarea & gt; & Lt; Button type = "button" class = "btn-btn-kill" id = "saveNote" href = "javascript: zero (0);" Data-bind = "click: addNote, enable: hasInput" & gt; & Lt; I class = "icon-save" & gt; & Lt; / I & gt; Save note & lt; / Button & gt; & Lt; Script src = "https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"> gt; Side note: Just completely FWIW, I have new syntax for
ko.computed
No comments:
Post a Comment