Reputation: 2081
Somewhere in the application.js I am compiling I have this object and function:
chosen.coffee
Foo =
do_this: ->
$('.slider').slider()
$ ->
Foo.do_this()
This calls JQueryUI and turns one of my divs into a slider. Then user does stuff and re-renders that html. My question is, how do I get to call this function from a response.js.erb?
response.js.erb
$('big_body_thing').append('<div class="slider"></div>')
Foo.do_this??????
Upvotes: 1
Views: 171
Reputation: 1478
Add below code at the end of 'chosen.coffee' file to export Foo
:
root = exports ? this
root.Foo = Foo
Upvotes: 2