Reputation: 1482
Hi in my app when i click on addfields a form appears and when i try to submit that i am getting an error String is not a function . here is my code for add function
self.addTierFields = function (tier) {
self.Tiers.push(new Tier({
bothrate: self.bothrate(),
compoundratee: self.compoundratee(),
simplerate: self.simplerate(),
rate: self.rate()
}));
self.show(true);
};
and here is js fiddle link demo
Upvotes: 0
Views: 967
Reputation: 4354
self.bothrate
etc are not knockout observables at the time they are accessed in your code.
You have them defined in your html and they are just regular strings.
So try this instead:
self.addTierFields = function (tier) {
self.Tiers.push(new Tier({
bothrate: self.bothrate,
compoundratee: self.compoundratee,
simplerate: self.simplerate,
rate: self.rate
}));
self.show(true);
};
Upvotes: 1
Reputation: 354
In the snippet bellow
self.Tiers.push(new Tier({
bothrate: self.bothrate(),
compoundratee: self.compoundratee(),
simplerate: self.simplerate(),
rate: self.rate()
}));
There is no bothrate in LoanViewModel, I have also changed a number of things, understand the concepts of scope, meaning of $root,$parent,$data.
here is the new fiddle
http://jsfiddle.net/b81mjt9k/10/
Upvotes: 0