Module: RjsHelper
- Defined in:
- app/helpers/rjs_helper.rb
Instance Method Summary collapse
-
#js_append_element_to(element, content) ⇒ Object
Appends the given content to the given element ————————————————————–.
- #js_hide_element(element) ⇒ Object
- #js_hide_element_by_dom_id(element) ⇒ Object
-
#js_prepend_element_to(element, content) ⇒ Object
Appends the given content to the given element ————————————————————–.
-
#js_redirect_to(url) ⇒ Object
Redirects the user to the given URL using javascript ————————————————————–.
-
#js_remove_element(element) ⇒ Object
Removes the given element from the DOM ————————————————————–.
-
#js_remove_element_by_dom_id(element) ⇒ Object
Like
js_remove_element
, but with the element’s dom_id ————————————————————–. -
#js_replace_element(element, content) ⇒ Object
Replaces the given selector with the given content —————————————————————————-.
-
#js_replace_element_by_dom_id(element, content) ⇒ Object
Like js_replace_element, but with the element’s dom_id —————————————————————————-.
-
#js_scroll_to(element, offset_top = 0) ⇒ Object
Scrolls to the given element on the page.
-
#js_show_element(element) ⇒ Object
—————————————————————- Show / Hide / Toggle —————————————————————-.
- #js_show_element_by_dom_id(element) ⇒ Object
- #js_toggle_element(element) ⇒ Object
-
#js_update_element(element, content) ⇒ Object
Updates the content of the given selector with the given content —————————————————————————-.
-
#js_update_element_by_dom_id(element, content) ⇒ Object
Like js_update_element, but with the element’s dom_id —————————————————————————-.
Instance Method Details
#js_append_element_to(element, content) ⇒ Object
Appends the given content to the given element
21 22 23 |
# File 'app/helpers/rjs_helper.rb', line 21 def js_append_element_to(element, content) rjs_method :append_element, :element => element, :content => content end |
#js_hide_element(element) ⇒ Object
69 70 71 |
# File 'app/helpers/rjs_helper.rb', line 69 def js_hide_element(element) rjs_method :hide_element, element end |
#js_hide_element_by_dom_id(element) ⇒ Object
77 78 79 |
# File 'app/helpers/rjs_helper.rb', line 77 def js_hide_element_by_dom_id(element) js_hide_element(element) end |
#js_prepend_element_to(element, content) ⇒ Object
Appends the given content to the given element
27 28 29 |
# File 'app/helpers/rjs_helper.rb', line 27 def js_prepend_element_to(element, content) rjs_method :prepend_element, :element => element, :content => content end |
#js_redirect_to(url) ⇒ Object
Redirects the user to the given URL using javascript
57 58 59 |
# File 'app/helpers/rjs_helper.rb', line 57 def js_redirect_to(url) rjs_method :redirect_to, url_for(url) end |
#js_remove_element(element) ⇒ Object
Removes the given element from the DOM
45 46 47 |
# File 'app/helpers/rjs_helper.rb', line 45 def js_remove_element(element) rjs_method :remove_element, element end |
#js_remove_element_by_dom_id(element) ⇒ Object
Like js_remove_element
, but with the element’s dom_id
51 52 53 |
# File 'app/helpers/rjs_helper.rb', line 51 def js_remove_element_by_dom_id(element) js_remove_element(element) end |
#js_replace_element(element, content) ⇒ Object
Replaces the given selector with the given content
33 34 35 |
# File 'app/helpers/rjs_helper.rb', line 33 def js_replace_element(element, content) rjs_method :replace_element, :element => element, :content => content end |
#js_replace_element_by_dom_id(element, content) ⇒ Object
Like js_replace_element, but with the element’s dom_id
39 40 41 |
# File 'app/helpers/rjs_helper.rb', line 39 def js_replace_element_by_dom_id(element, content) js_replace_element(element, content) end |
#js_scroll_to(element, offset_top = 0) ⇒ Object
Scrolls to the given element on the page. If the symbol :top
is given, the page will scroll to top without having to specify a certain element
Additionally, an offset can be given as the second parameter. This is e.g. useful in cases of layouts with a fixed top navbar.
96 97 98 99 100 101 102 |
# File 'app/helpers/rjs_helper.rb', line 96 def js_scroll_to(element, offset_top = 0) if element == :top rjs_method :scroll_to_top, offset_top else rjs_method :scroll_to_element, :element => element, :args => [offset_top] end end |
#js_show_element(element) ⇒ Object
Show / Hide / Toggle
65 66 67 |
# File 'app/helpers/rjs_helper.rb', line 65 def js_show_element(element) rjs_method :show_element, element end |
#js_show_element_by_dom_id(element) ⇒ Object
73 74 75 |
# File 'app/helpers/rjs_helper.rb', line 73 def js_show_element_by_dom_id(element) js_show_element(element) end |
#js_toggle_element(element) ⇒ Object
81 82 83 |
# File 'app/helpers/rjs_helper.rb', line 81 def js_toggle_element(element) rjs_method :toggle_element, element end |
#js_update_element(element, content) ⇒ Object
Updates the content of the given selector with the given content
9 10 11 |
# File 'app/helpers/rjs_helper.rb', line 9 def js_update_element(element, content) rjs_method :update_element, :element => element, :content => content end |
#js_update_element_by_dom_id(element, content) ⇒ Object
Like js_update_element, but with the element’s dom_id
15 16 17 |
# File 'app/helpers/rjs_helper.rb', line 15 def js_update_element_by_dom_id(element, content) js_update_element(element, content) end |