Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><a href="http://jsfiddle.net/x6H8s/22/" rel="nofollow">Solution jsfiddler</a></p> <p>Actually you were not adding the autocomplete event with newly added testboxes i.e. it was not working</p> <pre><code> &lt;script src="http://cdnjs.cloudflare.com/ajax/libs/knockout/2.1.0/knockout-min.js" type="text/javascript"&gt; &lt;/script&gt; &lt;div class='liveExample'&gt; &lt;p&gt;You have asked for &lt;span data-bind='text: gifts().length'&gt;&amp;nbsp;&lt;/span&gt; gift(s)&lt;/p&gt; &lt;table data-bind='visible: gifts().length &gt; 0'&gt; &lt;thead&gt; &lt;tr&gt; &lt;th&gt;Gift name&lt;/th&gt; &lt;th&gt;Price&lt;/th&gt; &lt;th /&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody data-bind='foreach: gifts'&gt; &lt;tr&gt; &lt;td&gt; &lt;input data-bind='value: name' class='tags' /&gt;&lt;/td&gt; &lt;td&gt; &lt;input data-bind='value: price' /&gt;&lt;/td&gt; &lt;td&gt;&lt;a href='#' data-bind='click: $root.removeGift'&gt;Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/tbody&gt; &lt;/table&gt; &lt;button data-bind='click: addGift'&gt;Add Gift&lt;/button&gt; &lt;button data-bind='enable: gifts().length &gt; 0' type='submit'&gt;Submit&lt;/button&gt; &lt;/div&gt;​ </code></pre> <p>and script is like</p> <pre><code>//For autocomplete extender genarting members var GiftModel = function (gifts) { var self = this; self.gifts = ko.observableArray(gifts); self.addGift = function () { self.gifts.push({ name: "", price: "" }); var availableTags2 = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; $(".tags").autocomplete({ source: availableTags2 }); }; self.removeGift = function (gift) { self.gifts.remove(gift); }; }; var viewModel = new GiftModel([ { name: "", price: "" } ]); $(document).ready(function () { ko.applyBindings(viewModel); var availableTags = [ "ActionScript", "AppleScript", "Asp", "BASIC", "C", "C++", "Clojure", "COBOL", "ColdFusion", "Erlang", "Fortran", "Groovy", "Haskell", "Java", "JavaScript", "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" ]; $(".tags").autocomplete({ source: availableTags }); });​ </code></pre> <p>below is a sample ajax call made to server ,on complishion of that one you can assign your variable at client side,make sure tthe variable is global so you can access it between different functions</p> <pre><code> function getResult() { var URL = "/Home/GetResult"; var typeJSON = {}; typeJSON["sql"] = $("#sqltext").val(); $.ajax({ type: "POST", url: URL, data: typeJSON,//data to be send to server //omit above data tag if not required to send data to server success: function (data) { //on success you can assign your variable here }, failure: function (data) { //on faliure of ajax call can show some message here } }); } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload