this is my textbox auto complete function. its loading fine but i want to load suggestions only user enter this " [ " sign. user can enter multiple times in one textbox. like this
hello [world] this is [my] sample.
function getOnChangeText() { var str = $("#txtMyText").val(); if (str = "[") { var strText = str.replace("[", ""); $.ajax({ url: '../../Page/TextSearch', type: 'POST', dataType: 'json', data: JSON.stringify({ translateText: strText }), contentType: 'application/json; charset=utf-8', success: function (data) { $("#txtMyText").autocomplete({ source: data }); } }); $("#txtDisplayText").focus(); } }
Answers
You are only verifying when the user enters a string value, so if the user enters "[[" or "[[[" and so on it will not enter the if block. So instead of verifying for a fixed value such as "[" you need to evaluate the string and then check if it contains the "[" character, and if so, continue the autocomplete.
Also this is javascript, and I am not sure but I think this is a Xamarin only forum so you should stick to Xamarin related questions. Personally I have never used javascript with Xamarin.