1 Reply Latest reply on Feb 27, 2014 2:44 AM by BHAKTA RANJAN SATAPATHY

    Function call over Event OnLoad

    Uwe Stockemer

      Hello

       

      i tried to call a function on the even OnCall in the file index.erb here the example:

      <body onload="<%= url_for :controller => :Views, :action => :enable_scanner %>">

      but it dosent work, but with a java script function it works could anybody help?

       

      if i call this action with a hyperlink :

              <li><a href="<%= url_for :controller => :Views, :action => :enable_scanner %>">enable scanner</a></li>

      it works

        • Re: Function call over Event OnLoad
          BHAKTA RANJAN SATAPATHY

          Hi,

           

          Looks like you are trying to call controller method.

          When this ruby line executed (<%= url_for :controller => :Views, :action => :enable_scanner %>), it will give you html output like /app/Views/enable_scanner, which is a link to controller call.

          i.e

          <body onload="/app/Views/enable_scanner">

           

          So to call a ruby method on body onload ,

           

          1: Create a js method which will do ajax call to controller method i.e enable_scanner

          2: Call that js method onload.

           

          Thanks

          Bhakta

          1 of 1 people found this helpful