Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/470.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Moodle_Javascript_Php_Jquery_Moodle - Fatal编程技术网

Javascript Moodle

Javascript Moodle,javascript,php,jquery,moodle,Javascript,Php,Jquery,Moodle,嗨,我对穆德尔是个新手。我一直在尝试测试我的Javascript是否运行,但没有结果。以下是我所拥有的: 在/videojs/amd/src中,我用一个简单的命令创建了一个test.js文件 define(['jquery'], function() { return { init: function() { // Put whatever you like here. $ is available // to you as

嗨,我对穆德尔是个新手。我一直在尝试测试我的Javascript是否运行,但没有结果。以下是我所拥有的:

在/videojs/amd/src中,我用一个简单的命令创建了一个test.js文件

define(['jquery'], function() {
    return {
        init: function() {
            // Put whatever you like here. $ is available
            // to you as normal.
                alert("It changed!!");
        }
    };
});
然后我咕哝了一声文件,一切都成功了,并且缩小了。但当我转到页面时,它不会运行。现在我读了,我看到上面写着

The idea here is that we will run the 'init' function from our (PHP) code to set things up. This is called from PHP like this...

我在哪里调用这个PHP?

在您输出的页面的某个地方,您需要添加如下调用:

$PAGE->requires->js_call_amd('PLUGINTYPE_videojs/test', 'init);
您的示例并不完全清楚您正在创建哪种类型的插件,因此无论您创建哪种类型的插件,您都需要将其放入站点的相应子目录中,例如/mod/videojs、/local/videojs等。,然后添加一些PHP脚本作为插件的入口点,并从那里调用js_call_amd函数。

Thnk!我在安装函数中添加了它,比如说/classes/plugin.php和$page->requires->js\u call\u amd'media\u videojs/test',init';成功了。非常感谢。