Class: Easypiechart::MainController
- Inherits:
-
Volt::ModelController
- Object
- Volt::ModelController
- Easypiechart::MainController
- Defined in:
- app/easypiechart/controllers/main_controller.rb
Instance Method Summary collapse
Instance Method Details
#before_index_remove ⇒ Object
28 29 30 31 32 |
# File 'app/easypiechart/controllers/main_controller.rb', line 28 def before_index_remove @watches.each do |watch| watch.stop end end |
#index_ready ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/easypiechart/controllers/main_controller.rb', line 4 def index_ready @watches = [] @elem = `$("#" + #{first_element}.id)` if @elem if attrs. begin JSON.parse(attrs.).each do |option, value| `#{@elem}.data(#{option}, #{value})` end rescue Object => e Volt.logger.error "'options' attribute passed to EasyPieChart must be a string that is valid, parsable JSON. Error was #{e}" end end `#{@elem}.easyPieChart();` @watches << -> { update_value(attrs.percent) }.watch! end end |
#update_value ⇒ Object
22 23 24 25 26 |
# File 'app/easypiechart/controllers/main_controller.rb', line 22 def update_value if @elem `#{@elem}.data('easyPieChart').update(#{attrs.percent})` end end |