我在asp.net中制作了一个自定义的可折叠字段集控件.我用jquery来添加切换效果.该控件工作得很好,但是当我在更新面板中使用我的fieldsets时,由于document.ready,我在回发后松开了我的jquery逻辑.
现在我已经阅读了关于Jquery的新Live()函数,但我没有得到它的工作.我做错了什么?有人答案吗?
非常感谢
我的Jquery代码是:
$(document).ready(function() {
$.fn.collapse = function(options) {
var defaults = { closed: false }
settings = $.extend({}, defaults, options);
return this.each(function() {
var obj = $(this);
obj.find("legend").addClass('SmartFieldSetCollapsible').live("click", function() {
if (obj.hasClass('collapsed')) {
obj.removeClass('collapsed').addClass('SmartFieldSetCollapsible'); }
$(this).removeClass('collapsed');
obj.children().next().toggle("slow", function() {
if ($(this).is(":visible")) {
obj.find("legend").addClass('SmartFieldSetCollapsible');
obj.removeAttr("style");
obj.css({ padding: '10px' });
obj.find(".imgCollapse").css({ display: 'none' });
obj.find(".imgExpand").css({ display: 'inline' });
}
else {
obj.css({ borderLeftColor: 'transparent', borderRightColor: 'transparent', borderBottomColor: 'transparent', borderWidth: '1px 0px 0px 0px', paddingBottom: '0px' });
obj.find(".imgExpand").css({ display: 'none' }); …Run Code Online (Sandbox Code Playgroud)