Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

knockout js

Posted on 2015-01-25
1
Medium Priority
?
93 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
These days, all we hear about hacktivists took down so and so websites and retrieved thousands of user’s data. One of the techniques to get unauthorized access to database is by performing SQL injection. This article is quite lengthy which gives bas…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
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…

660 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