(function($){ $.fn.extend({ dialog: function(options) { var defaults = { width: 'auto', height: 'auto', closeOnEscape: true, closeText: 'Zamknij', autoCenter: true } var options = $.extend(defaults, options); $(this).width(options.width).height(options.height); if(options.closeOnEscape == true){ $(document).keypress(function(event) { if(event.keyCode == 27) { $(this).hide(); } }); } if(options.autoCenter == true){ var winH = $(window).height(); var winW = $(window).width(); var modH = $(this).height(); var modW = $(this).width(); var left = (winW - modW) / 2; var top = (winH - modH) / 2; $(this).css('top', top); $(this).css('left', left); } $(this).show(); } }); })(jQuery);
... no i mam też problem. Otóż w 16 linii w/w kodu chcę aby to całe okienko dialogowe się zamykało, a jednak się nie zamyka. Doszedłem do wniosku, że this w tej linii odwołuje się do document, a nie do tego okienka. Próbowałem to zrobić poprzez
ale i tak nie działa. Może wiecie w jaki sposób to rozwiązać? Z góry dziękuje
$(this).parent().hide();