So verwenden Sie Javascript in Plug-in

Release time:2017年07月26日 Author:Catfish CMS Reading volume:58549

We all know how to use javascript in the page, then we in the design of Catfish CMS plug-in can also use javascript? The answer is of course yes, and the use of javascript in the plugin is also very simple.


Here, let's take a look at how to use javascript in the plugin.


Still  use the system comes with the announcement plug-in example, assuming  that we want to join the plug-in javascript code, how to do it?


There are two ways:

One is  directly to the javascript code and html code mixed into the plug-in  (plug-in how to make reference please refer to this site related  articles)

The second method is to put the javascript code into a separate file, and then in the plug-in reference to this file.


The first method  is very simple, when the javascript code is not very complicated  circumstances, we can directly use the first method. But  when the code is more complicated, if you still mix with the html code,  you may feel that the code is not concise, then we can use the second  method, the javascript code in a separate file.


The following figure is the simplest plugin that contains only one file:

Now we  hope to be able to use javascript in the plug-in, we first in this file  where the folder to create a new folder, named "js", as shown below:

Then we built a javascript file in the "js" folder, assuming we built a file called "announcement.js". Then we will come to the realization of the js file to the plug-in.


As with the reference style file, we need to use the built-in function "$this->import()", the actual code is as follows:

$this->import('js/announcement.js')

Then we assign it to $data with the html code, and finally display the content with the built-in function "add".


Very simple, as long as a simple line of code can refer to the external javascript file.


Original article, reproduced please specify:So verwenden Sie Javascript in Plug-in | Catfish(鲶鱼) CMS

Reward

I want to comment Sign in to post a comment


Latest release

如何给导航菜单添加图标

我们访问某些网站的时候,会发现导航菜单的文字前面有一个小图标,如下图所示: 在鲶鱼系统...

bootstrap4导航菜单的二级下拉菜单鼠标悬停显示jQuery怎...

bootstrap的导航菜单默认都是通过鼠标点击来展开的,有时我们为了让浏览者有更好的访...

jQuery如何获取当前元素的ID

jQuery是一个优秀的JavaScript库,给前端页面的制作带来了极大的方便,鲶鱼系...

鲶鱼系统如何使用bootstrap4以及其辅助标签

Catfish(鲶鱼) CMS从4.9.3版开始原生支持bootstrap4,Catfi...

关于捐助款项的使用情况通报

自鲶鱼系统创建开始,截止于2019年7月31日,累计收到捐助款项179.46元(包含截止...

bootstrap4如何实现div的水平居中以及垂直居中

bootstrap是一款十分流行的前端组件库,我们在制作模板的时候,使用bootstra...

How to use the Catfish CMS system

Section 1: How to add articles

Management background is composed of five bl...

Section 2: to the article to add c...

In the previous section, we talked about how...

Section 3: Add a menu to your site

In the previous section we talked about how ...

Section 4: Page Setup

To the last section we have learned to use t...

Section 5: Change website name, LO...

By the end of the previous section, we have ...

Copyright © 2015 - 2019 Catfish(鲶鱼) CMS
Catfish(鲶鱼) CMS〖181836340〗 Catfish(鲶鱼) CMS 二群〖292598750〗

   I want to leave a message
Catfish(鲶鱼) CMS V 4.9.24