0

I have few input elements which are wrapped on 'if' binding. Problem when I open a popup from one of these elements and setting a value from popup to opener, popup says element not found. Here's the code.

<!-- ko if: enableCustomerCode() -->
<a href="#" onclick="return getCustomerList();">
   <img src="<%=path%>/images/blueSearch1.JPG" alt="Search Customer" border="0" height="16" />
</a>
<input type="hidden" id="customername" />
<input type="hidden" id="customerid" />
<input type="hidden" id="customercode" />
<input type="hidden" id="custOuId" />
<input type="hidden" id="custOuCode" />
<input type="hidden" id="customerallcurrency" />
<!-- /ko -->

function onPopUpClose() {
    modal.orderBooking().customerCode($("#customercode").val());
}

It says $("#customercode").val() is null or undefined.

Sorry, it was my code problem, but now jquery autocomplete is not working

autoCompleteJQ($("#abc"), "ENTITYNAMEFORORDER", function(suggestion) {
        modal.orderBooking().customerId(suggestion.dbId);
        modal.orderBooking().customerCode(suggestion.id);
        modal.orderBooking().customerName(suggestion.code);
    });

Here abc comes under if binding

Karthik Menon
  • 71
  • 1
  • 4

1 Answers1

1

You're writing jQuery with a bit of Knockout mixed in. That isn't how Knockout works. Knockout needs to control the DOM. #abc probably doesn't exist when you are looking for it, because it's in the if section.

You should make a custom binding handler so that Knockout can call autoCompleteJQ when it inserts the node. This may be what you need.

Community
  • 1
  • 1
Roy J
  • 42,522
  • 10
  • 78
  • 102