I have been trying to insert an html button as the last element of an jquery ui autocomplete list. The button is supposed to open a popup window with the option of adding a new element to the autocomplete list. This is the code which 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 );
});
In order to be able to insert the 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 is: The button appears fine and does what it is supposed to (opens a popup window) However after opening the popup window all the code from the html input gets inserted into the textbox. This is the logical behaviour, since the code is inserted as a label, but would anybody know what would be the best way to insert an html button as the last element of the autocomplete?
Thanks in advance