Kod
function Popup(){
this.html = '';
this.title = '';
this.resize = false;
this.width = 400;
this.init = function(){
var bar = $('<div class="popup-bar"></div>');
var close = $('<div class="popup-close">x</div>').click( function() {
$(this).parent().parent().remove();
});
var title = $('<div class="popup-title">'+this.title+'</div>');
var content = $('<div class="popup-content">'+this.html+'</div>');
bar.append(close).append(title);
var win = $('<div class="popup-window"></div>');
win.append(bar);
win.append(content);
$('body').append(win);
};
this.url = function(url){
$.get(url,
function(data){
this.html = data;
this.init();
});
}
}
this.html = '';
this.title = '';
this.resize = false;
this.width = 400;
this.init = function(){
var bar = $('<div class="popup-bar"></div>');
var close = $('<div class="popup-close">x</div>').click( function() {
$(this).parent().parent().remove();
});
var title = $('<div class="popup-title">'+this.title+'</div>');
var content = $('<div class="popup-content">'+this.html+'</div>');
bar.append(close).append(title);
var win = $('<div class="popup-window"></div>');
win.append(bar);
win.append(content);
$('body').append(win);
};
this.url = function(url){
$.get(url,
function(data){
this.html = data;
this.init();
});
}
}
Oraz wywołanie :
Kod
$(document).ready( function(){
pop = new Popup();
pop.url('/');
});
pop = new Popup();
pop.url('/');
});
Dostaję błąd, że obiekt nie ma takiej metody.
Kod
Uncaught TypeError: Object #<Object> has no method 'init'
Co zrobiłem źle? Dodam, że wcześniej nie bawiłem się w klasy pisząc skrypty
