0
我正在開發一個jQuery插件來創建模態窗口,所以,現在,我想在隱藏它之後還原元素原始狀態。jQuery插件開發保存元素原始狀態
有人可以幫助我嗎?
謝謝!
----更新---
對不起,
我想保存的HTML元素在某些時候表現出來的地方,然後把存儲的數據回來時將其隱藏。
這是我的插件:
(function ($) { // v2ui_modal
var methods = {
show: function (options) {
var _this = this;
var defaults = {
showOverlay: true,
persistentContent: true
};
var options = $.extend(defaults, options);
if (!_this.attr('id')) {
_this.attr('id', 'v2ui-id_' + Math.random().toString().replace('.', ''));
}
if (options.showOverlay) {
$('<div />', { // overlay
id: 'v2-ui-plugin-modal-overlay-' + this.attr('id'),
css: {
zIndex: ($.topZIndex() + 1),
display: 'none',
position: 'fixed',
width: '100%',
height: '100%',
top: 0,
left: 0
}
}).addClass('v2-ui').addClass('plugin').addClass('overlay').appendTo('body');
};
_this.css({
zIndex: ($.topZIndex() + 2),
position: 'fixed'
});
_this.center();
$('#v2-ui-plugin-modal-overlay-' + _this.attr('id')).fadeIn(function() {
_this.fadeIn();
});
},
hide: function() {
var _this = this;
_this.fadeOut();
$('#v2-ui-plugin-modal-overlay-' + _this.attr('id')).fadeOut(function() {
$('#v2-ui-plugin-modal-overlay-' + _this.attr('id')).remove();
if ((_this.attr('id')).substr(0, 8) == 'v2ui-id_') {
_this.removeAttr('id');
};
});
}
};
jQuery.fn.v2ui_modal = function (methodOrOptions) {
if (methods[methodOrOptions]) {
methods[methodOrOptions].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof methodOrOptions === 'object' || !methodOrOptions) {
methods.show.apply(this, arguments);
};
};
})(jQuery);
太模糊。發佈一些代碼。你有什麼嘗試? – Utkanos 2012-08-17 08:20:12
從我們目前獲得的信息來看,我要做的是:'$(「。yourElement」)。show();' – 2012-08-17 08:20:23
我們怎麼可能幫您提供這麼少的信息... – 2012-08-17 08:28:36