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.
Constant Summary
Constants inherited from Event
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
#__internal_prepare_for_dispatch__, #__internal_record_path__, #__internal_set_current_target__, #__js_call__, #__js_method_names__, #bubbles?, #default_prevented?, #immediate_propagation_stopped?, #init_event, #propagation_stopped?
Constructor Details
#initialize(type = "beforeunload", init = nil) ⇒ BeforeUnloadEvent
Returns a new instance of BeforeUnloadEvent.
814 815 816 817 |
# File 'lib/dommy/event.rb', line 814 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.
819 820 821 |
# File 'lib/dommy/event.rb', line 819 def return_value @return_value end |
Instance Method Details
#__js_get__(key) ⇒ Object
821 822 823 824 825 826 827 828 |
# File 'lib/dommy/event.rb', line 821 def __js_get__(key) case key when "returnValue" @return_value else super end end |
#__js_set__(key, value) ⇒ Object
830 831 832 833 834 835 836 837 |
# File 'lib/dommy/event.rb', line 830 def __js_set__(key, value) case key when "returnValue" @return_value = value.to_s else super end end |