rétablir le support des URLs avec fragments
Une proposition de remplacement de la méthode ajaxHandler() permettant de rétablir le support des URLs avec fragments du type "http://monsite.com #fragment_a_charger" :
ajaxHandler: function (target, instance){
var cache = instance.opener().data('lity-ajax-cache') || {};
if ( target.indexOf(' #') > -1 ){
var fragment = target.split(' #')[1]
target = target.split(' #')[0];
}
if (cache[target]) {
//console.log("CACHE for "+target);
if ( fragment ) content = $(content).find('#'+fragment);
return $('<div class="lity-content-inner"></div>').append(cache[target]);
}
var _deferred = $.Deferred;
var deferred = _deferred();
var failed = function (){
deferred.reject($('<span class="error lity-error"></span>').append('Failed loading ajax'));
};
$.get(target)
.done(function (content){
cache[target] = content;
instance.opener().data('lity-ajax-cache', cache);
if ( fragment ) content = $(content).find('#'+fragment);
deferred.resolve($('<div class="lity-content-inner"></div>').append(content));
})
.fail(failed);
return deferred.promise();
},