Author Topic: Plugin Not loading Javascript  (Read 4044 times)

Offline mikbull

  • Jr. Member
  • **
  • Posts: 12
Plugin Not loading Javascript
« on: July 26, 2012, 10:59:11 AM »
Hi there,

I'm just messing around trying to create a very simple plugin. I have a folder under plugins/ 'addressbook_import/' with a .php and .js file.

I have loaded the plugin in the main.inc.php.

The Source:

addressbook_import.php
========================================
<?php
class addressbook_import extends rcube_plugin
{
        private $test;

        function init()
        {
                $this->include_script('addressbook_import.js');
        }

}
?>

addressbook_import.js
================================================
$(document).ready(function(){
if (window.rcmail) {
alert('hello');
}
}

Currently the .js file isn't included at all. (Not visible in FireBug)

What am I doing wrong?



Offline mikbull

  • Jr. Member
  • **
  • Posts: 12
Re: Plugin Not loading Javascript
« Reply #1 on: July 26, 2012, 11:19:11 AM »
Problem Solved...

It seems the API validates the js before it attaches the script. I had a syntax error in the .js file. See the section in red.

addressbook_import.js
================================================
$(document).ready(function(){
if (window.rcmail) {
alert('hello');
}
}
);