Module: Engine2::ActionOnChangeSupport

Included in:
ActionFormSupport, ActionListSupport
Defined in:
lib/engine2/action.rb

Defined Under Namespace

Classes: OnChangeAction, OnChangeGetAction, OnChangePostAction

Instance Method Summary collapse

Instance Method Details

#on_change(field, trigger_on_start = false, &blk) ⇒ Object



590
591
592
593
594
595
596
# File 'lib/engine2/action.rb', line 590

def on_change field, trigger_on_start = false, &blk
    node_name = :"#{field}_on_change"
    nd = node.define_node node_name, (blk.arity <= 2 ? OnChangeGetAction : OnChangePostAction)
    nd.*{request &blk}

    fields! field, remote_onchange: {action: node_name, record: blk.arity > 2, trigger_on_start: trigger_on_start}
end