2011-03-20 35 views
0

我有这样的按钮:巴顿成为了浏览器的历史可以追溯到后被禁止

<button value="1" name="submit" disabled="true" id="signup-bb" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-disabled ui-state-disabled ui-button-text-only" role="button" aria-disabled="true"> 

点击该网页上的一些单选按钮后,“注册-BB”按钮becaming可用

启用“注册-BB”按钮:

 $("signup-bb").removeAttr('disabled'); 
     $("signup-bb").attr('aria-disabled', false); 
     $("signup-bb").removeClass('ui-button-disabled'); 
     $("signup-bb").removeClass('ui-state-disabled'); 

后,我的按钮喜气洋洋的那样:

<button value="1" name="submit" aria-disabled="false" id="signup-bb" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button"> 

当我点击这个按钮表单获取发送到服务器,经过一些处理后,我重定向到另一个控制器,所有看起来不错,但如果我点击返回浏览器按钮,我来到前一页与按钮,我做可点击(“注册-BB”),但这个按钮禁用状态有:

<button value="1" name="submit" disabled="true" id="signup-bb" class="ui-button ui-widget ui-state-default ui-corner-all ui-button-disabled ui-state-disabled ui-button-text-only" role="button" aria-disabled="true"> 

任何思考如何解决这个问题,当用户单击后退以显示他这是之前的状态?

回答

0

发生这种情况的原因是因为当页面第一次加载按钮被禁用,并且这是页面存储在浏览器历史记录中的状态。然后,当单击单选按钮并启用signup-bb按钮时,您使用JavaScript对DOM进行了一些更改,但这些更改未保存到浏览器历史记录中。当用户点击后退按钮时,页面在保存状态下从历史记录加载,即禁用按钮。

+0

我能做些什么来解决这个问题? – Reg 2011-03-21 02:46:31

0

A排序解决办法的,我只是用来解决这个问题是重新启用上卸载事件的按钮:

(function ($) { 
    // creates the jQuery UI button treatment for all button elements 
    $('button').button(); 
    $(window).unload(function() { 
     // re-enables the jQuery UI button treatment on all 
     // button elements on the window unload event 
     $('button').button('enable'); 
    }); 
})(jQuery); 
+0

提供给任何阅读此答案的人:在11月13日东部时间美国东部夏令时间上午11点左右给出的这个答案的低估是另一个用户报复我给他们的公平倒退的倒退... – gabe 2012-11-13 20:43:10