Cześć mam mały problem z funkcją w js.
Daną funkcję niżej możemy wywołać:
<a href="#" data-name="contact" class="jsOpen">Contact</a>
Pobiera nam zawartość pliku z serwera i pokazuje go w postaci wysuwanego panelu.
Niestety jak mam np już wysunięty taki panel np. z opisem firmy i mam tam odnośnik do:
<a href="#" data-name="contact" class="jsOpen">Contact</a>
Wtedy dana funkcja nie działa.
Nie chce się odpalić w divie:
<div class="jsContent">
</div>
W czym może być problem? że poza tym divem jsContent działa w nim już nie.
Z góry dziękuje za jakąkolwiek pomoc.
var slidepanel = function() { this.init(); };
slidepanel.prototype = {
init: function () { var $this = this;
if(!this._setVars()) return;
this._setEvents();
},
_setVars: function () {
this._container = $('.jsContainer');
if(!this._container) return false;
this._content = this._container.find('.jsContent');
if(!this._content) return false;
this._background = $('.jsBackground');
if(!this._background) return false;
this._openButton = $('.jsOpen');
if(!this._openButton) return false;
this._closeButton = $('.jsClose');
if(!this._closeButton) return false;
return true;
},
_setEvents: function () {
var e = this;
var openpanel = false;
this._openButton.on('click', function (t) {
t.preventDefault(),
e._open(this),
openpanel = true
}),
this._closeButton.on('click', function (t) {
t.preventDefault(),
e._close(),
openpanel = false
}),
$(window).on('hashchange', function () {
e._checkBack()
})
},
_open: function (e) {
var t = this,
n = $(e).data('name');
$.get('views/' + n + '.html', {
}, function (e) {
t._content.html(e),
t._background.addClass('show'),
t._container.addClass('show'),
$('html, body').css('overflow', 'hidden'),
document.location.hash = n
})
},
_close: function () {
$('html, body').removeAttr('style'),
this._background.removeClass('show'),
this._container.removeClass('show'),
document.location.hash = ''
},
_checkBack: function () {
document.location.hash || this._close()
},
};