Class: Dommy::BeforeUnloadEvent
Overview
‘BeforeUnloadEvent` — `beforeunload` event. Setting `return_value` to a non-empty string (or calling `preventDefault`) signals the browser to prompt the user before navigating away.
Instance Attribute Summary collapse
-
#return_value ⇒ Object
Returns the value of attribute return_value.
Attributes inherited from Event
Instance Method Summary collapse
- #__js_get__(key) ⇒ Object
- #__js_set__(key, value) ⇒ Object
-
#initialize(type = "beforeunload", init = nil) ⇒ BeforeUnloadEvent
constructor
A new instance of BeforeUnloadEvent.
Methods inherited from Event
#__js_call__, #__prepare_for_dispatch__, #__record_path__, #__set_current_target__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?
Constructor Details
#initialize(type = "beforeunload", init = nil) ⇒ BeforeUnloadEvent
Returns a new instance of BeforeUnloadEvent.
790 791 792 793 |
# File 'lib/dommy/event.rb', line 790 def initialize(type = "beforeunload", init = nil) super @return_value = (read_init(init, "returnValue") || "").to_s end |
Instance Attribute Details
#return_value ⇒ Object
Returns the value of attribute return_value.
795 796 797 |
# File 'lib/dommy/event.rb', line 795 def return_value @return_value end |
Instance Method Details
#__js_get__(key) ⇒ Object
797 798 799 800 801 802 803 804 |
# File 'lib/dommy/event.rb', line 797 def __js_get__(key) case key when "returnValue" @return_value else super end end |
#__js_set__(key, value) ⇒ Object
806 807 808 809 810 811 812 813 |
# File 'lib/dommy/event.rb', line 806 def __js_set__(key, value) case key when "returnValue" @return_value = value.to_s else super end end |