Retrieving an element with jQuery inside a knockout event

I played with knockout.js with jQuery and I am very new to knockout.js

My sample code and code is here: http://jsfiddle.net/Ninjanoel/ADYN6/

Basically, I am trying to create a screen for entering lottery numbers as a test of my knowledge, and now I am trying to check the input of a text field, and then apply special effects to the input field if [onBlur], the text field is invalid.

I have a “LotteryApp”, with an observable array of “Lines”, with a regular array of [5] ko observables, to serve as my inputs or “Number Boxes”. I use a template to display each "Line" and another template inside to display "Boxes".

I would like to name the jquery text block 'color fade' [red to bg color] in the text box if the input is incorrect. But in the onBlur function that I created, I cannot find anything in any argument passed to the function to help me call something like myTextBox = jQuery(arguments.something), so that I can do something likejQuery(myTextBox).colourFade()

<input type="text" data-bind="value:n, event:{blur: $parent.onBlur }, uniqueName:true, disable: $parent.isLD" class="lotteryNumber" maxlength="2"/>

is the code in my internal template processing onBlur.

self.onBlur = function()...

is the function that I want to call in the blur event.

, , . ko.bindingHandlers.myBinding, "" "update" "init", jQuery (element).colourFade(), , , , , , "init" "update" ( ), , (, "keyup"?), , -, ko.observable, .

:

data-bind="event : {blur : myMethod}", , myModel.myMethod, html, .

+5
1

jQuery event , :

self.onBlur = function(data, event) {
    console.log(event.target);
}
+8

All Articles