i have an .js.rjs file, that must be used in many places.
How can i reuse it ?
For example, in my .js.rjs file i need something like this:
page << ( render "widely_used_stuff" )
where "widely_used_stuff" is a widely_used_stuff.js.rjs file, that contains the code, used in many places.
Also, i need to pass the variables to widely_used_stuff.js.rjs, like in this way:
page << ( render "widely_used_stuff", :locals => {:custom_script => my_script} )
Update 1
I have tried following ways from .js.rjs file:
render "widely_used_stuff"
Rails complains on it, because it require开发者_StackOverflows this "partial" to be "erb" partial
Following way:
render :file => "controller/widely_used_stuff.js.rjs"
Rails don't complains, but "widely_used_stuff.js.rjs" is not inserted to .js.rjs file, that called render. I have checked the XHR response.
I think, the problem is in the caller .js.rjs file, because it is not a erb...
Hi have you tried render "controller/widely_used_stuff.js.rjs"
?
page << render(:file => "common/index.js.rjs")
i hope could help .
render :partial => 'view_directory/widely_used_stuff.js.rjs'
精彩评论