Re: Pushing Javascript Helper to external file.

Julian ''Julik'' Tarkhanov
Tue, 11 Oct 2005 18:09:16 -0000

On 11-okt-2005, at 19:24, Rube wrote:
>
> I just copied the result of remote_function.  Anyhow, as you can
> probably tell this is going to cause a problem if my app is
> deployed to a subdirectory, say /inventory, then the Ajax.Updater
> should call ''/inventory/store_room/get_note'' + id, but it
won''t.  I
> need that :url magic in my external .js file.
>
> Is there a solution to this?

class JavascriptController <  ApplicationController
     before_filter :javascript_header
  layout nil
   def index
     render :text=>''alert("Hello from the
controller")''
   end

    def whatever
       @items_belonging_to_user = Item.all_find_by_owner_id(@user.id)
         # will render whatever.rhtml where you can put some javascript
   end

   private

    def javascript_header
     response.env["Content-type"] = "text/javascript"
   end
end




--
Julian "Julik" Tarkhanov