asp.net mvc 4 - jQuery 2.1.4 issue -
i added autocomplete field view , works fine until make selection error in function:
// support: android 2.3 // workaround failure string-cast null input jquery.parsejson = function( data ) { return json.parse(data + ""); };
it says there invalid character. if change this, don't error:
// support: android 2.3 // workaround failure string-cast null input jquery.parsejson = function( data ) { if (data !== undefined) return json.parse(data + ""); else return null; };
is there missing here? code simple , have used in numerous views:
<table> <tr> <td> @html.displaynamefor(x=>x.state)  @html.textboxfor(x=>x.state, new { id = "txtstate", style = "width:50px"}) </td> <td> @html.displaynamefor(x=>x.zip)  @html.textboxforwithtitle(x=>x.zip, new { id = "txtzip", style = "width:50px"}) </td> </tr> </table>
js:
$("#txtstate").autocomplete({ delay: 0, minlength: 0, autofocus: true, source: function (request, response) { $.ajax({ type: 'get', data: { 'data': request.term }, datatype: 'json', url: '@url.action("getstates")', success: function (data) { response($.map(data, function (obj) { return { value: obj.text, label: obj.value } })); } }); }, open: function () { $("#txtstate").autocomplete("widget").width(150); }, select: function (event, ui) { var test = ui.item.value; } }).focus(function () { $("#txtstate").autocomplete('search', $("#txtstate").val()); }).blur(function () { var keyevent = $.event("keydown"); keyevent.keycode = $.ui.keycode.enter; $(this).trigger(keyevent); if (neworold != "old") { $("#txtstate").val($("#txtstate").val()); } });
Comments
Post a Comment