Created
March 2, 2015 13:26
-
-
Save nyangry/579d50a162c64fc0fa77 to your computer and use it in GitHub Desktop.
簡易dirty check
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict' | |
# input[type="text"]、textarea の入力値を保持しておく処理を行う | |
# remote: true なフォーム等の submit() の手前で、 | |
# 現在の値と、保持されている入力値が同じ場合は、submit() 処理へ進まない場合等に利用する。 | |
$ -> | |
class BeforeValue | |
selector: 'input[type="text"], textarea' | |
constructor: -> | |
@setEvents() | |
setEvents: -> | |
$('body').on 'keyup, focusin', @selector, -> | |
$(@).data 'before', $(@).val() | |
before_value = new BeforeValue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment