Solved

knockout js

Posted on 2015-01-25
1
83 Views
Last Modified: 2015-01-26
i have a custom binding defined as below, if i have a value it is working fine but if the value is empty i am getting an exception object is not a function at this line valueAccessor()(thisValue);
if i put a condition to check i it has a value, then the binding is not applied to that field.
ko.bindingHandlers.getter = {
        init: function (element, valueAccessor, allBindingsAccessor, context) {
              
            var $el = $(element),
                thisValue = $el.val() || $el.text();
           valueAccessor()(thisValue);
        }
    }
0
Comment
Question by:gvkr
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 22

Accepted Solution

by:
ambience earned 500 total points
ID: 40570251
Well, this makes sense because when you invoke

valueAccessor()(thisValue);

Open in new window


you first get the property value using

valueAccessor()

Open in new window


and then treat it as a function, which becomes

'undefined'(thisValue)

Open in new window


when the returned value is undefined. You should check the return value of valueAccessor() first.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Wufoo.com provides powerful tools for surveying targeted groups, and utilizing data from completed surveys to find trends, discover areas of demand or customer expectation, and make business decisions on products or services.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question