使用ajax启用禁用jquery ui按钮
我很难理解启用/禁用
jquery ui按钮的选项.
通常在过去我使用的任何按钮: jQuery(".mybutton").prop('disabled',false); 根据您是否要启用/禁用它,它将是false / true. 这似乎也适用于jquery ui按钮.我在做的是检查某个计数并在您第一次加载页面时禁用该按钮. 但有人可以通过删除某些东西来改变计数值(通过AJAX调用): //delete jQuery(document).on("click",".deletebutton",function() { if (confirm("Are you sure you want to delete?")) { var hash = jQuery(this).data("delete"); var $this = jQuery(this); jQuery.ajax({ url: "index.php?option=com_cam&task=delete&hash="+ hash +"&"+getToken()+"=1&format=raw",dataType: 'json',type: "POST",success: function(data){ if (data.type == 'error') { //error message printed to user } else { $this.closest("tr").remove(); //deleted so decrement and check if you have exceeded your limit count=count-1; if (count >= limit) { //disable buttons jQuery( ".mybutton" ).button( "option","disabled",true ); } else { //enable add buttons and hide message jQuery( ".mybutton" ).button( "option",false ); //jQuery(".mybutton").attr('disabled',false); //jQuery(".mybutton").prop('disabled',false); } } } }); } }); 然后这应该再次启用按钮. prop或attr或者这个post似乎都不适合我.只有当我这样做时: jQuery( ".mybutton" ).button( "option",false ); 我想我不明白为什么道具在禁用我的按钮时可以在这种情况下不起作用?始终使用按钮setter是最佳做法吗?
在引擎盖下,该按钮已被禁用,但是,您看到的是一个按钮,其样式已由jQuery UI设置.
jQuery UI不使用disabled属性设置样式(如[disabled = disabled]).相反,它向按钮添加了两个类,其中包含禁用的按钮样式:ui-button-disabled,ui-state-disabled. 我知道有四种方法可行. >推荐方式:调用jQuery(‘.mybutton’).button(‘disable’) 希望这能解释为什么它以这种方式工作. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- 详解C语言的exp()函数和ldexp()函数以及frexp()函
- cocos2d js 调用object-c 方法
- FLASH 之 AMF 格式
- c 11 – 使用std :: unique_ptr / std :: shared
- [Tips] Ajax error: Access to restricted URI d
- c# – AspIdentiy ApplicationUserManager是静态
- oracle_linux_6_64(bit)上安装oracle11gR2数据
- c# – 营销人员的Sitecore webforms保存项目操作
- Cocos Creator开发环境配置
- 关于Flashbuilder的破解