Solved

knockout js

Posted on 2015-01-25
1
88 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

Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
This video teaches users how to migrate an existing Wordpress website to a new domain.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

634 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