Bug 17790: Fix js error on undefined autocomplete(...).data(...)
Bug 17418 moved some code to js_includes.inc. But if #findborrower does not exist, you cannot define _renderItem. Trivial fix. Test plan: [1] Find a page where this include is used and #findborrowers is absent. Like about.pl [2] Without this patch, you will have a js error in the js console. [3] With this patch, you should no longer have it. Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Signed-off-by: Nick Clemens <nick@bywatersolutions.com> Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
This commit is contained in:
parent
2f07f7b48e
commit
d4b15e40b0
1 changed files with 10 additions and 8 deletions
|
@ -89,7 +89,7 @@
|
|||
[% IF ( CircAutocompl ) %]
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$( "#findborrower" ).autocomplete({
|
||||
var obj = $( "#findborrower" ).autocomplete({
|
||||
source: "/cgi-bin/koha/circ/ysearch.pl",
|
||||
minLength: 3,
|
||||
select: function( event, ui ) {
|
||||
|
@ -97,13 +97,15 @@
|
|||
$("#patronsearch").submit();
|
||||
return false;
|
||||
}
|
||||
})
|
||||
.data( "ui-autocomplete" )._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
.data( "ui-autocomplete-item", item )
|
||||
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.dateofbirth + " " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
}).data( "ui-autocomplete" );
|
||||
if( obj ) {
|
||||
obj._renderItem = function( ul, item ) {
|
||||
return $( "<li></li>" )
|
||||
.data( "ui-autocomplete-item", item )
|
||||
.append( "<a>" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") <small>" + item.dateofbirth + " " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "</small></a>" )
|
||||
.appendTo( ul );
|
||||
};
|
||||
}
|
||||
});
|
||||
</script>
|
||||
[% END %]
|
||||
|
|
Loading…
Reference in a new issue