Como agregar un .js file
  • goyo7575 May 2012
    He tratado de agregar un archivo .js con:

    static function Load() {
    Plugin::Attach ( 'view.add_js' , array( __CLASS__ , 'agregarjava' ) );
    }

    function agregarjava() {

    $js_name = "AntiSpam.js";
    return $js_name;

    }



    NO SE AGREGA EL ARCHIVO .JS QUE ESTOY INCLUYENDO

    COMO ES LO CORRECTO?
  • DamianDamian May 2012
    I would use this hook instead "register.before_render", so it would look like this:

    Plugin::Attach ( 'register.before_render' , array( __CLASS__ , 'agregarjava' ) );

    And in your function "agregarjava", I would add:

    View::AddJs('http://www.example.com/path/to/javascript.js');

    So it would look like this:

    function agregarjava() {
    View::AddJs('http://www.example.com/path/to/javascript.js');
    }
This discussion has been closed.
← All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership