Sha256: 885d04fb7957974d177cfbe174111e636049915fd97c4687c4929ecccce792cb
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# backtick_javascript: true module Browser; module DOM; class Element < Node class Form < Element def_selector "form" # Capture the content of this form to a new {FormData} object, # # @return [FormData] def form_data FormData.create(self) end # Returns true if form is valid, false otherwise def valid? `#@native.reportValidity()` end # Submit a form. This will NOT fire a submit event. def submit `#@native.submit()` end # Submit a form, optionally with a button argument. # This will fire a submit event. def request_submit(submitter = nil) if submitter `#@native.requestSubmit(#{submitter.to_n})` else `#@native.requestSubmit()` end end # Submit a form using AJAX. def ajax_submit(&block) data = form_data data = data.to_h unless encoding == 'multipart/form-data' HTTP.send(method, target, form_data, &block) end # Reset a form. This will fire a reset event. def reset `#@native.reset()` end alias_native :action alias_native :action= alias_native :method alias_native :method= alias_native :target alias_native :target= alias_native :encoding alias_native :encoding= # Return a NodeSet containing all form controls belonging to this form element. def controls NodeSet[Native::Array.new(`#@native.elements`)] end end end; end; end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
opal-browser-0.3.5 | opal/browser/dom/element/form.rb |
opal-browser-0.3.4 | opal/browser/dom/element/form.rb |