so have dropdown called category, , table 2 columns language , name.
category determine scope (books, magazines, etc.) language dropdown fixed list of values (english, spanish, etc.)
now need values of name autocompleted source scoped both global category, row's language
<tr> <td> <select name="row.language"></select> </td> <td> <textarea name="row.name"></textarea> </td> <tr>
what have tried far:
$('select[name="row.language"]').change(function () { getnameautocomplete($(this).parent().parent()); }); function getnameautocomplete(row) { var lang = $(row).find("select[name='row.language']").val(); console.log("outer: lang = " + lang); $(row).find('textarea[name="row.name"]').autocomplete({ source: function (request, callback) { var cat = $("#ddlcategory").val(); console.log("inner: lang = " + lang); encodeddata = { category: cat, language: lang, term: request.term }; $.ajax({ type: "post", url: getnameautocompletelistactionurl, datatype: 'json', data: encodeddata, beforesend: function (jqxhr, settings) { $("#loadinganim").show(); }, complete: function (jqxhr, textstatus) { $("#loadinganim").hide(); }, success: function (data, textstatus, jqxhr) { callback(data); }, error: function (jqxhr, textstatus, errorthrown) { callback(); } }); } }); }
as may have noticed, doesn't work. inner lang
null, whereas outer lang
has correct selected value.
appreciate if guys can give me advice how achieve this.
====
added jsfiddle http://jsfiddle.net/harryt/mdktg4mt/1/
and strange enough, works on jsfiddle! although if closely, jsfiddle url above, lang
not defined (black instead of blue color) inside source: function (request, callback)
Comments
Post a Comment