how to use rails3-jquery-autocomplete plugin for multiple words autocomplete
Tag : jquery , By : Jason Vance
Date : March 29 2020, 07:55 AM
I wish this helpful for you rails3-jquery-autocomplete plugin? It seems that it doesn't support multiple autocomplete, you need to modify the plugin code!! If you insist on your former ideas, follow my steps. run bundle show rails3-jquery-autocomplete to get the plugin working directroy mate /lib/autocomplete.rb define_method("autocomplete_#{object}_#{method}") do
arr = params[:term].split(",")
unless params[:term] && params[:term].empty?
items = object.to_s.camelize.constantize.where(["LOWER(#{method}) LIKE ?", "#{arr[arr.size-1]}%"]).limit(limit).order(order)
else
items = {}
end
render :json => json_for_autocomplete(items, method)
|
How to highlight input words in autocomplete jquery ui
Date : March 29 2020, 07:55 AM
To fix this issue It seems to me you should overwrite the _renderItem method to have custom rendering of the items. The code could be about the following: $("#studentName").autocomplete({/* all your parameters*/})
.data("autocomplete")._renderItem = function (ul, item) {
var newText = String(item.value).replace(
new RegExp(this.term, "gi"),
"<span class='ui-state-highlight'>$&</span>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<div>" + newText + "</div>")
.appendTo(ul);
};
var $elem = $("#studentName").autocomplete({/* all your parameters*/}),
elemAutocomplete = $elem.data("ui-autocomplete") || $elem.data("autocomplete");
if (elemAutocomplete) {
elemAutocomplete._renderItem = function (ul, item) {
var newText = String(item.value).replace(
new RegExp(this.term, "gi"),
"<span class='ui-state-highlight'>$&</span>");
return $("<li></li>")
.data("item.autocomplete", item)
.append("<div>" + newText + "</div>")
.appendTo(ul);
};
}
|
Ignoring HTML tags to highlight matching words
Date : March 29 2020, 07:55 AM
Hope this helps I want to replace HTML template content with new one after highlighting the words those match the search input. , Firstly I am sorry for quick tested answer. Here is your answers: var reg = new RegExp("[\>][^\<\>.]*"+tag+"[^\<\>.][\<]*","gi");
var reg = new RegExp("[\>][^\<\>.]*"+tag+"[^\<\>.]*[\<]*","gi");
var text = "<div>fireman has killed fire</div>";
text = "<div><highlight>fire</highlight>man has killed <highlight>fire</highlight></div>";
|
Highlight certain words in input form without using tags?
Date : March 29 2020, 07:55 AM
Any of those help The only way I can think of is to use getBoundingClientRect() and draw an overlay over the box while the user is writting. getBoundingClientRect() is expensive, but running at user typing speed is no problem actually.
|
How highlight words jquery ui autocomplete
Date : March 29 2020, 07:55 AM
|