Javascript

Navigation:  Components > Hook >

Javascript

Previous pageReturn to chapter overviewNext page

This Hook used to register JavaScript file.
 
Step1: Register Call call back. See below format:
 
App::Module('Hook')

   ->setHookName("Javascript")

   ->setAction("register_Javascript_Code")

   ->Register(Call Back Class Name, Call Back Function Name);

 

Name

Type

Description

Call Back Class Name

Mandatory

Class Name of  call back function

Call Back Function Name

Mandatory

Call back function

 

Step 2: Register resource in Call back function:

In call back function we return text content with JavaScript code.
 

See below example:
 
class Component_Appstore_Register extends appRain_Base_Component
{
   public function init(){
       App::Module('Hook')
           ->setHookName('Javascript')
           ->setAction("register_Javascript_Code")
           ->Register(get_class($this),"register_Javascript_Code");
 
   }
 
   public function register_Javascript_Code()
   {
      return App::Helper('Utility')->fetchFile($this->attachMyPath('addons/js/appcart.js'))
       .  App::Helper('Utility')->fetchFile($this->attachMyPath('addons/js/appcheckout.js'))
       .  App::Helper('Utility')->fetchFile($this->attachMyPath('addons/zoom/zoom.js'));
   }
}