Click here to Skip to main content
15,886,774 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
when i am adding getting error like

Uncaught Error: Unable to parse bindings.
Message: ReferenceError: AcSource is not defined;
Bindings value: options: $root.acSource, optionsText: 'Name', optionsValue: 'Value', value: AcSource

What I have tried:

i have wrote in cshtml like below
HTML
<div class="textBoxStyling mandatory">
                               <h4>Ac Source</h4>

                           </div>


and in knockout have added
JavaScript
acSource: ko.observableArray([{ Name: "EB", Value: 1 }, { Name: "DG", Value: 2 }, { Name: "EB & DG", Value: 3 }])
Posted
Updated 23-Sep-16 23:10pm
v2

1 solution

try this


HTML
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
    <title></title>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js" type="text/javascript"></script>
    
</head>
<body> 
    <select data-bind="options: acSource, value:AcSource, optionsText: 'Name' , optionsValue: 'Value' "></select>       
    <script> 
        function myModel() {          
            this.acSource = ko.observableArray([{ Name: "EB", Value: 1 }, { Name: "DG", Value: 2 }, { Name: "EB & DG", Value: 3 }]);
            this.AcSource = ko.observable();
        }
        ko.applyBindings(new myModel());

    </script>
   
</body>
</html>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900