I am trying to insert an html button as the last element of a jquery ui autocomplete list. The button should open a pop-up window with the ability to add a new item to the autocomplete list. This is the code that inserts the button inside the autocomplete list:
data.push({label: '<input type="button" name="btn_name_field" id="btn_name_field" title="Create" class="button firstChild" value="Add new">'}); response(data);
This is the function that opens the popup:
$(document).on("click", "#btn_name_field", function () { open_popup("Street_Address", 400, 180, "", true, false, {"call_back_function":"set_return","form_name":"EditView"}, "single", true ); });
To be able to embed html inside as a βlabelβ, I had to use this function:
$[ "ui" ][ "autocomplete" ].prototype["_renderItem"] = function( ul, item) { return $( "<li></li>" ) .data( "item.autocomplete", item ) .append( $( "<a></a>" ).html( item.label ) ) .appendTo( ul ); };
What happens: the button looks normal and does what it should (opens a popup window) However, after opening the popup window, all the code from the html input is inserted into the text box. This is a logical behavior as the code is inserted as a label, but does anyone know what would be the best way to insert the html button as the last autocomplete element?
Thank you in advance
source share