`
gazeldx
  • 浏览: 107008 次
  • 性别: Icon_minigender_1
  • 来自: 苏州
社区版块
存档分类
最新评论

prevent double-click

 
阅读更多
First we talk about the button.
Button or Submit
Solution 1: disable_with => "Begin Service"
Rails can use :disable_with => "Begin Service".
Example:
= button_tag "Begin Service", root_path, :disable_with => "Begin Service" 

This will not work when use RailsVersion Under(maybe 3.2) for image_submit_button.
So we can fix it like this:
Solution 2:
$("#an_image_submit").attr("disabled", true)

Link Add class = 'nodouble' to a link
Solution 1:
$(".nodouble").live "click", -> 
  $(this).click -> return false 

Solution 2:
$("body").on "click", ".nodouble", (e) -> 
  $(this).attr "onclick", "" 
  $(this).on "click", (e) -> false 

Solution 3: For Ajax query: CSS:
#'pointer-events: none' will not work in IE, So this solution is not suitable for IE. This solution's benifit is that it will change the CSS of the clicked link.
a.disabled { opacity: 0.5; pointer-events: none; cursor: default } 

$(".nodouble").livequery "click", (e) -> 
  e.preventDefault() 
  a = $(this) a.addClass('disabled') 

Because Solution 3 can not work with IE, So we should do more work like this: Solutions 4
$(".nodouble").livequery "click", (e) -> 
  e.preventDefault() 
  a = $(this) return false if a.data("clicked") a.data("clicked", true) 
  a.addClass('disabled')
分享到:
评论

相关推荐

    Diskeeper 2008 v12.0.759.0

    Frag Shield is the first and only technology to prevent system file fragmentation gets better. No more need to run a manual and resource-intensive process. Frag Shield抯 MFT fragmentation ...

    CodeProtector

    users simply need to double-click the installer to automatically install the add-in. After successful installation, the **CodeProtector** menu item will appear under the Tools menu in Visual Studio. ...

    BURNINTEST--硬件检测工具

    2) Double click (or Open) the downloaded ".exe" file 3) Follow the prompts UnInstallation ============== Use the Windows control panel, Add / Remove Programs Requirements ============ - Operating ...

    PLSQL.Developer v11.0.0.1762 主程序+ v10中文包+keygen

    Breakpoints form now has a Go to menu item (also double-click). When selected you will be taken to the source location in a Program Window. Program Window enhancements Code Contents sorting mode is ...

    Google C++ Style Guide(Google C++编程规范)高清PDF

    link ▶All header files should have #define guards to prevent multiple inclusion. The format of the symbol name should be <PROJECT>_<PATH>_<FILE>_H_. To guarantee uniqueness, they should be based on ...

    cuteEditor6.0

    To prevent this type of error from occurring, developers can use MaxHTMLLength or MaxTextLength in the Cute Editor to limit the length of the user抯 input. Apply security to control user ...

Global site tag (gtag.js) - Google Analytics