Skip to content

Instantly share code, notes, and snippets.

@nyangry
Created March 2, 2015 13:26
Show Gist options
  • Save nyangry/579d50a162c64fc0fa77 to your computer and use it in GitHub Desktop.
Save nyangry/579d50a162c64fc0fa77 to your computer and use it in GitHub Desktop.
簡易dirty check
'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