javascript - Knockout share a binding handler -


I am currently building a huge number of apps in knockout. There are three types of numbers in my app: percentages, decimal and large numbers and I have each type of custom binding handle.

Recognition I have a number of input Baindinghandlr is also designed to ensure reads each keyboard that it has a number of input (app attractive range CSS animation and stuff - it's just a bare Bones have been snatched for example).

Now to input the verification check and number, tie me twice with the variable because you will see right below in Bela.

  & lt; Input data-bind = "number: test data, percentage: test data" & gt;   

I think it is unnecessary as the flapping my HTML markup and should be a strong way to trigger both handlers at the same time.

My question: It is possible to create number verification scripts as a function, which can then be shared / included within number formatting operators;

I am still a newbie, so I am still unsure about its boundaries.

See Bella: P>

Yes, you only remove the number init in its own function can that change it:

  to .bindingHandlers.number = {init: function (element) {/ * ... * /}};   

In:

  var numberInit = function (element) {/ * ... *};   

Just say it in your other init like this:

  init: work (element, value access) {numberInit (element); / * ... * /}   

or if you want to correct this' reference:

  init: function (element, valueAccessor) { NumberInit.apply (this, argument); / * ... * /}    

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -