Dopop('opac-addbybiblionumber.pl?biblionumber=[% biblionumber | html %]');
return false;
});
- $(".addrecord").on("click",function(){
- addRecord('[% biblionumber | html %]');
- return false;
+ $("body").on("click", ".addtocart", function(e){
+ e.preventDefault();
+ var biblionumber = $(this).data("biblionumber");
+ addRecord( biblionumber );
});
- $(".cartRemove").on("click",function(){
- delSingleRecord('[% biblionumber | html %]');
- return false;
+ $("body").on("click", ".cartRemove", function(e){
+ e.preventDefault();
+ var biblionumber = $(this).data("biblionumber");
+ delSingleRecord( biblionumber );
});
- $(".clearsh").on("click", function(){
+ $(".clearsh").on("click", function(e){
+ e.preventDefault();
return confirmDelete(MSG_DELETE_SEARCH_HISTORY);
});
//]]>
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
[% IF ( incart ) %]
- <li><a class="incart cart[% biblio.biblionumber | html %] addrecord" href="#">In your cart</a> <a class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li>
+ <li><a data-biblionumber="[% biblio.biblionumber | html %]" class="addtocart incart cart[% biblio.biblionumber | html %] addrecord" href="#">In your cart</a> <a data-biblionumber="[% biblio.biblionumber | html %]" class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li>
[% ELSE %]
- <li><a class="addtocart cart[% biblio.biblionumber | html %] addrecord" href="#">Add to your cart</a> <a style="display:none;" class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li>
+ <li><a data-biblionumber="[% biblio.biblionumber | html %]" class="addtocart cart[% biblio.biblionumber | html %] addrecord" href="#">Add to your cart</a> <a style="display:none;" data-biblionumber="[% biblio.biblionumber | html %]" class="cartRemove cartR[% biblio.biblionumber | html %]" href="#">(remove)</a></li>
[% END %]
[% END %]
[% IF Koha.Preference( 'opacbookbag' ) == 1 %]
[% IF ( SEARCH_RESULT.incart ) %]
- <span class="actions"><a class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">In your cart</a> <a class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="delSingleRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">(remove)</a></span>
+ <span class="actions"><a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#">In your cart</a> <a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#">(remove)</a></span>
[% ELSE %]
- <span class="actions"><a class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="addRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">Add to cart</a> <a style="display:none;" class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#" onclick="delSingleRecord('[% SEARCH_RESULT.biblionumber | html %]'); return false;">(remove)</a></span>
+ <span class="actions"><a data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="addtocart cart[% SEARCH_RESULT.biblionumber | html %]" href="#">Add to your cart</a> <a style="display:none;" data-biblionumber="[% SEARCH_RESULT.biblionumber | html %]" class="cartRemove cartR[% SEARCH_RESULT.biblionumber | html %]" href="#">(remove)</a></span>
[% END %]
[% END # / IF opacbookbag %]
</div>
+/* global MSG_BASKET_EMPTY MSG_RECORD_IN_BASKET MSG_RECORD_ADDED MSG_NRECORDS_IN_BASKET MSG_NRECORDS_ADDED MSG_NO_RECORD_SELECTED MSG_NO_RECORD_ADDED MSG_IN_YOUR_CART MSG_RECORD_REMOVED MSG_CONFIRM_DEL_BASKET MSG_CONFIRM_DEL_RECORDS MSG_ITEM_IN_CART MSG_ITEM_NOT_IN_CART */
+
//////////////////////////////////////////////////////////////////////////////
// BASIC FUNCTIONS FOR COOKIE MANAGEMENT //
//////////////////////////////////////////////////////////////////////////////
}
function delSingleRecord(biblionumber){
+ biblionumber = String( biblionumber );
var nameCookie = "bib_list";
var valCookie = readCookie(nameCookie);
var arrayRecords = valCookie.split("/");
var pos = jQuery.inArray(biblionumber,arrayRecords);
- arrayRecords.splice(pos,1);
+ arrayRecords.splice( pos, 1 );
valCookie = arrayRecords.join("/");
writeCookie( nameCookie, valCookie );
updateBasket( arrayRecords.length-1 );