JavaScript plug-in development tutorial (3)_javascript skills
WBOY
Release: 2016-05-16 16:17:48
Original
1123 people have browsed it
1, opening analysis
In the previous two articles, we mainly talked about "how to develop plug-ins using jQuery" and the way to combine procedural design with object-oriented design
How to design a plug-in, both methods have their own advantages and disadvantages. This series of articles is learning-oriented. You can decide how to use it in specific scenarios. So starting from this article today, we will take you through the development of your own plug-in library from shallow to deep in the form of examples. Hey hey hey, stop talking nonsense and get to the point. Directly upload the actual renderings:
As you can see, this is a tab plug-in, which we may come into contact with when we make single-page applications ("SPA") every day. Take today's example,
We are building a system based on the BS structure, which will consist of several modules. They are all components of the system. Through this plug-in, we can effectively manage our modules
The experience form and user interactivity of
will be analyzed in detail below.
(2), example analysis
(1), first determine what this plug-in does. Let’s take a look at how the plug-in is called and the configuration parameter description. The following code:
"bigbear.ui.createTab" contains two parameters, the first is the dom node object, and the second is the plug-in parameter option. "buttonText" represents the text description of the operation button in the "Tab" plug-in.
"result" is an array, which contains the properties of the tab item, including text description, the URL used to make requests when clicking the tab item, "showClose" represents whether the tab option displays a close button.
"status" represents the status of the option, which is open by default and may be closed, respectively: 1-open, 0-closed.
(2), what are the functions involved
Dynamically generate relevant option entries through optional parameters, as shown in the following example:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn