Práctica recomendada en Rails 3.2: ¿Adjuntar funciones javascript a un objeto de ventana?

I have a rails application where a lot of views are rendered in javascript (i.e. rendered from remote actions). After rails compiles my coffee script files into javascript I am finding that, due to namespace separation I believe, these views cannot reference any javascript functions unless I attach the functions to the window object. E.g.

window.finishEditingNode = ->
    $("#this_area").hide(1000)
    $("#that_form").show(1000)

This is what I have been doing but it doesn't seem right to be attaching virtually even function to the window object. Is there a better way around this?

preguntado el 10 de marzo de 12 a las 06:03

1 Respuestas

Attach a context to window, and define anything under that context.

respondido 10 mar '12, 07:03

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.