CN102981821B - A kind of event agent's method and system - Google Patents
A kind of event agent's method and system Download PDFInfo
- Publication number
- CN102981821B CN102981821B CN201210417546.8A CN201210417546A CN102981821B CN 102981821 B CN102981821 B CN 102981821B CN 201210417546 A CN201210417546 A CN 201210417546A CN 102981821 B CN102981821 B CN 102981821B
- Authority
- CN
- China
- Prior art keywords
- sub
- event
- event handler
- elements
- execution data
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Landscapes
- Storage Device Security (AREA)
- Document Processing Apparatus (AREA)
Abstract
The present invention provides a kind of event agent's method and system, this method includes:Event handler is bound with father's element of daughter element or the element more more advanced than father's element in advance;After event handler is triggered, all daughter elements of traversal and element bound in the event handler find the daughter element for responding the event handler according to for the preset identity property of daughter element;Event handler is obtained from the default storage attribute of the daughter element found executes data, and operation is executed according to the execution data.According to technical solution provided by the invention, the treatment effeciency of front end page is improved.
Description
[ technical field ] A method for producing a semiconductor device
The invention relates to a front-end page development technology in the field of Internet, in particular to an event agent method and system.
[ background of the invention ]
In the process of developing the front-end page of the merchant center, the conventional event processing method is to bind an event processor for each sub-element according to requirements, and the front-end page usually has many sub-elements, so that a plurality of event processors need to be bound, but when a large number of event processors are bound, if a plurality of event processors need to be continuously or simultaneously triggered, the sub-elements bound by the event processors need to be continuously or simultaneously triggered, so that the efficiency of the front-end page is low, and memory leakage or browser crash is caused.
In addition, when each sub-element responds to the same event handler, the required execution data is different in many times, so that certain data needs to be stored in the tag of each sub-element, for example, the required execution data is stored in the attribute of the sub-element such as ID, name, title, etc. When the sub-element responds to the event handler, a plurality of execution data are required to be supported, so in order to store the execution data, a plurality of attributes are required to be set to store the execution data, so that the code in the front-end page is long, and the updating and maintenance of the code are not facilitated.
[ summary of the invention ]
The invention provides an event agent method and system, which improve the processing efficiency of a front-end page.
The specific technical scheme of the invention is as follows:
according to a preferred embodiment of the present invention, an event agent method for binding an event handler with a parent element of a child element or an element higher than the parent element in advance, comprises:
after the event processor is triggered, traversing all sub-elements of the elements bound with the event processor, and finding the sub-elements responding to the event processor according to the preset identification attributes of the sub-elements;
and the event processor acquires execution data from the found preset storage attribute of the sub-element and executes operation according to the execution data.
In the above method, the storage attribute stores a combination of one or more execution data.
In the above method, the event handler includes an element name field;
binding an event handler with a parent element of a child element or an element higher than the parent element in advance as: the name of an element in an element name field in an event handler is set to the name of a parent element or the name of an element higher than the parent element.
In the above method, the finding of the sub-element responding to the event handler according to the identifier attribute preset for the sub-element specifically includes:
finding the sub-element containing the identification attribute from the traversed sub-elements, wherein the value of the identification attribute indicates the sub-element of the event processor.
In the above method, the event handler includes an execute function field;
the event processor executes the operation according to the execution data specifically as follows:
the event handler inputs the acquired execution data and the child element responding to the event handler as parameters into the execution function acquired from the execution function field.
An event broker system comprising: a binding unit and an event processor; wherein,
a binding unit for binding an event handler with a parent element of a child element or an element higher than the parent element in advance;
the event processor is used for traversing all the sub-elements of the elements bound with the event processor after being triggered, and finding the sub-elements responding to the event processor according to the preset identification attributes of the sub-elements; and the method is also used for acquiring execution data from the preset storage attribute of the found sub-element and executing operation according to the execution data.
In the above system, the storage attribute stores a combination of one or more execution data.
In the above-mentioned system, the first and second sensors are arranged in a single circuit,
the event handler includes an element name field;
the binding unit binds the event handler with a parent element of a child element or an element higher than the parent element in advance, specifically: the name of an element in an element name field in an event handler is set to the name of a parent element or the name of an element higher than the parent element.
In the above system, the event handler finds the sub-element responding to the event handler according to the identifier attribute preset for the sub-element, specifically:
finding the sub-element containing the identification attribute from the traversed sub-elements, wherein the value of the identification attribute indicates the sub-element of the event processor.
In the above-mentioned system, the first and second sensors are arranged in a single circuit,
the event handler includes an execute function field;
the event processor executes an operation according to the execution data, specifically:
the acquired execution data and the sub-element of the processor responding to the event are input into the execution function acquired from the execution function field as parameters.
According to the technical scheme, the invention has the following beneficial effects:
more than one event processor is directly bound to a father element or a higher-level element, and a plurality of event processors can be triggered simultaneously through one element, so that the processing efficiency of a front-end page is improved, and the probability of memory leakage and browser crash is reduced.
In the invention, for each sub-element, only one attribute is used for storing all the execution data, and a plurality of attributes are not required to be set for respectively storing the execution data, so that the code length of a front-end page is effectively reduced, and the updating efficiency and the maintenance efficiency of the code are effectively improved, thereby reducing the workload of developers and improving the front-end development efficiency.
[ description of the drawings ]
FIG. 1 is a flow diagram of a preferred embodiment of a method of implementing an event broker in accordance with the present invention;
fig. 2 is a schematic structural diagram of a preferred embodiment of the event agent system implemented by the present invention.
[ detailed description ] embodiments
The basic idea of the invention is: binding an event handler with a parent element of a child element or an element higher than the parent element in advance; after the event processor is triggered, traversing all sub-elements of the elements bound with the event processor, and finding the sub-elements responding to the event processor according to the preset identification attributes of the sub-elements; and the event processor acquires execution data from the found preset storage attribute of the sub-element and executes operation according to the execution data.
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention will be described in detail with reference to the accompanying drawings and specific embodiments.
The present invention provides an event agent method, fig. 1 is a schematic flow chart of a preferred embodiment of the event agent method implemented by the present invention, as shown in fig. 1, the preferred embodiment includes the following steps:
step 101, setting an identification attribute and a storage attribute for the sub-element, wherein the identification attribute represents an event handler to which the sub-element responds, and the storage attribute stores execution data of the event handler.
Specifically, in the prior art, an event handler is bound under a sub-element, in the preferred embodiment, two attributes, namely an identifier attribute and a storage attribute, are set for the sub-element to which the event handler needs to be bound; the identification attribute is used as an identification of whether an event agent mechanism is applied or not, namely the identification attribute is used as a standard of whether an event handler is responded or not, if a sub-element has the identification attribute, the sub-element can respond to the event handler, and if the sub-element does not have the identification attribute, the sub-element cannot respond to the event handler; when the sub-element has the identification attribute, the value of the identification attribute is the identification of the event processor which is responded by the sub-element, so that the value of the identification attribute is used for determining which event processor the sub-element responds to, and the event processor and the value of the identification attribute have a one-to-one correspondence relationship.
The storage attribute is used for storing execution data which needs to be used when executing the operation corresponding to the event processor corresponding to the value of the identification attribute, and after the event processor is triggered, the execution data corresponding to the event processor in the storage attribute needs to be used for executing the corresponding operation; in the preferred embodiment, the storage attribute stores more than one execution data in a query manner, where the query manner refers to a manner of combining data by using characters, and combines data by using some special characters as connectors, and the common special characters are e.g. "&", "#" and the like; for example, the one or more execution data stored in the storage attribute may be: key1= value1# key2= value2# key3= value3, id =123& info = welome, etc.
Step 102, binding the event handler to which the child element responds with the parent element of the child element, or binding the event handler to which the child element responds with an element of a higher level than the parent element of the child element.
Specifically, in the prior art, event handlers are bound to child elements, in the preferred embodiment, event handlers that should be bound to child elements are bound to parent elements of the child elements, or event handlers are bound to elements higher than the parent elements of the child elements, such as grandparent elements; more than one event handler may be bound simultaneously on a parent element or an element at a higher level than the parent element.
Each event processor consists of four fields, namely an element name field, an event identification field, a trigger mode field and an execution function field; the element name field is the name of an element capable of responding to the event handler, the event identification field is the identifier of the event handler, the identifier of the event handler is the same as the value of the identification attribute in the sub-element capable of responding to the event handler, the trigger mode field is the trigger mode of the sub-element capable of responding to the event handler, and the trigger mode can be mouse click trigger, mouse sliding trigger, key trigger and the like; the execution function field is a specific execution function which needs to be used when the operation corresponding to the event handler is executed, for example, the executed operation may be a collection operation in the microblog, a cancel collection operation, or the like; in the preferred embodiment, it is necessary to bind an event handler to a parent element or an element higher than the parent element, and therefore, the binding of an event handler to a parent element or an element higher than the parent element can be realized by setting the name of an element in the element name field in the event handler to the name of the parent element or the name of an element higher than the parent element, instead of binding under a child element; it should be noted that the element name field, the trigger field, and the execution function field are fields that the event handler has in the prior art, and the event identification field is a field added to the event handler in the preferred embodiment, and is used to associate the event handler with the sub-element that responds to the event handler in the case that the event handler is not bound to the sub-element.
For example, the e.g. delete (wrap, "collect", "logic k", collectFunction) is an event handler, where wrap is the name of a parent element bound by the event handler, collect is the identifier of the event handler, click indicates that the trigger mode of the child element responding to the event handler is a mouse click trigger, and collectFunction indicates that the execution operation that can be implemented by using the execution function after the event is triggered is a collection.
Step 103, after the event handler is triggered, traversing all sub-elements of the element bound to the event handler, finding the sub-elements responding to the event handler according to the preset identification attribute of the sub-elements, acquiring execution data from the preset storage attribute of the found sub-elements, and executing operation according to the execution data.
Specifically, all elements are displayed in the form of tags on the front page, so that when the tags of the sub-elements on the front page are triggered, the sub-elements can be triggered; after a child element is triggered, if the event handler to which the child element responds is bound under the parent element of the child element, the parent element is also triggered, and if the event handler to which the child element responds is bound under an element higher than the parent element, the element higher than the parent element is also triggered, so that all event handlers bound under the parent element or the element higher than the parent element are triggered.
For each triggered event handler, the event handler will traverse all child elements contained in the parent element or all child elements contained under elements higher than the parent element, and determine whether the child element can respond to the event handler according to whether the child element has an identification attribute, so as to obtain child elements that can respond to the event handler; and the event processor judges whether the value is the same as the identification field of the event processor in the event processor or not in the sub-elements capable of responding to the event processor according to the value of the identification attribute of the sub-element, if so, the event processor indicates that the sub-element is the sub-element capable of responding to the event processor, and if not, the event processor indicates that the sub-element cannot respond to the event processor.
After finding the sub-element which can respond to the event processor, the event processor acquires the execution data required by the execution operation from the storage attribute of the sub-element; then, the event handler inputs the acquired execution data and the child element into the execution function acquired from the execution function field, and executes the corresponding operation.
Because the sub-elements are input into the execution function, the execution function can receive the modification of the current sub-elements by the user according to the requirements, so that the style of the label in the front-end page can be changed very conveniently; here, the acquired execution data is stored in the storage attribute in advance in a Query manner and cannot be directly input into the execution function, whereas JSON can convert a set of data into a character string and then can easily transfer this character string between functions, and therefore in the present preferred embodiment, the execution data will be input into the execution function in the form of a lightweight data interchange format (JSON, JavaScript object notification).
Examples
More than one collection label is arranged on the front-end page, when any one label is clicked, a dialog box pops up to enable a user to judge whether the product is collected or not, if the collection is confirmed, the corresponding identification of the product is transmitted to the background, after the response is successful, a red style is added to the label to indicate that the collection is carried out, and the same operation is carried out on the labels for canceling the collection.
The storage is correspondingly specifically set as follows:
<div id=”wrap”>
void (0) (= undeflag = "collect," nodeData = "id =123& name = mobile" > collection >
Void (0) (= collect = "nodeFlag =" collect "nodeData =" id =112& name = telephone "> collection >
Void (0) (= undeflag = "collect" nodeData = "id =163& name = fan" > collection >
Void (0) (= undeflag = "collect" nodeData = "id =567& name = air conditioner" > collection >
The specific settings corresponding to canceling the collection are as follows:
<div id=”wrap”>
void (0) (= collect = "nodeData =" id =478& name = hawthorn "> canceling collection >
Void (0) (= undeflag = "collect" undedata = "id =459& name = apple" > canceling collection >
Void (0) (= undeflag = "collect" undedata = "id =423& name = orange" > canceling collection >
Void (0) (= undeflag = "collect" undedata = "id =176& name = banana" > canceling collection >
To implement the above method, the present invention further provides an event agent system, fig. 2 is a schematic structural diagram of a preferred embodiment of implementing the event agent system according to the present invention, and as shown in fig. 2, the system includes: a binding unit 20, an event handler 21; wherein,
a binding unit 20 for binding the event handler 21 with a parent element of a child element or an element higher than the parent element in advance;
the event processor 21 is configured to traverse all sub-elements of the element bound to the event processor after being triggered, and find a sub-element responding to the event processor according to an identifier attribute preset for the sub-element; and the method is also used for acquiring execution data from the preset storage attribute of the found sub-element and executing operation according to the execution data.
Wherein the storage attribute stores a combination of more than one execution data.
Wherein the event handler includes an element name field;
the binding unit 20 binds the event handler 21 with the parent element of the child element or an element higher than the parent element in advance, specifically: the name of an element in an element name field in an event handler is set to the name of a parent element or the name of an element higher than the parent element.
The event handler 21 finds the sub-element responding to the event handler according to the identifier attribute preset for the sub-element, specifically:
finding the sub-element containing the identification attribute from the traversed sub-elements, wherein the value of the identification attribute indicates the sub-element of the event processor.
Wherein the event handler includes an execute function field;
the event processor 21 executes an operation according to the execution data, specifically:
the acquired execution data and the sub-element of the processor responding to the event are input into the execution function acquired from the execution function field as parameters.
In the technical scheme, more than one event processor is directly bound to a parent element or a higher-level element, and the event processors can be triggered simultaneously through one element, so that the processing efficiency of a front-end page is improved, and the probability of memory leakage and browser crash is reduced. Two attributes are set for each sub-element, one attribute is used for associating the sub-element with the event handler so that the event handler can find the corresponding sub-element, and the other attribute is used for storing the execution data, so that in the invention, only one attribute is used for storing all the execution data for each sub-element, and a plurality of attributes are not required to be set for respectively storing the execution data, thereby effectively reducing the code length of a front-end page, effectively improving the code updating efficiency and the maintenance efficiency, reducing the workload of developers and improving the front-end development efficiency. In addition, the event processor can return the current sub-element to the execution function, so that the style of the sub-element can be modified very conveniently, and the front-end development efficiency is improved.
The above description is only for the purpose of illustrating the preferred embodiments of the present invention and is not to be construed as limiting the invention, and any modifications, equivalents, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.
Claims (10)
1. An event agent method for binding an event handler with a parent element of a child element or an element higher than the parent element in advance, comprising:
after the event processor is triggered, traversing all sub-elements of the elements bound with the event processor, and finding the sub-elements responding to the event processor according to the preset identification attributes of the sub-elements;
and the event processor acquires execution data from the found preset storage attribute of the sub-element and executes operation according to the execution data.
2. The method of claim 1, wherein the storage attribute stores a combination of more than one execution data.
3. The method of claim 1, wherein the event handler includes an element name field;
binding an event handler with a parent element of a child element or an element higher than the parent element in advance as: the name of an element in an element name field in an event handler is set to the name of a parent element or the name of an element higher than the parent element.
4. The method according to claim 1, wherein the finding of the sub-element responding to the event handler according to the identifier attribute preset for the sub-element is specifically:
finding the sub-element containing the identification attribute from the traversed sub-elements, wherein the value of the identification attribute indicates the sub-element of the event processor.
5. The method of claim 1, wherein the event handler includes an execute function field;
the event processor executes the operation according to the execution data specifically as follows:
the event handler inputs the acquired execution data and the child element responding to the event handler as parameters into the execution function acquired from the execution function field.
6. An event brokering system, comprising: a binding unit and an event processor; wherein,
a binding unit for binding an event handler with a parent element of a child element or an element higher than the parent element in advance;
the event processor is used for traversing all the sub-elements of the elements bound with the event processor after being triggered, and finding the sub-elements responding to the event processor according to the preset identification attributes of the sub-elements; and the method is also used for acquiring execution data from the preset storage attribute of the found sub-element and executing operation according to the execution data.
7. The system of claim 6, wherein the storage attribute stores a combination of more than one execution data.
8. The system of claim 6,
the event handler includes an element name field;
the binding unit binds the event handler with a parent element of a child element or an element higher than the parent element in advance, specifically: the name of an element in an element name field in an event handler is set to the name of a parent element or the name of an element higher than the parent element.
9. The system according to claim 6, wherein the event handler finds the sub-element responding to the event handler according to an identification attribute preset for the sub-element, specifically:
finding the sub-element containing the identification attribute from the traversed sub-elements, wherein the value of the identification attribute indicates the sub-element of the event processor.
10. The system of claim 6,
the event handler includes an execute function field;
the event processor executes an operation according to the execution data, specifically:
the acquired execution data and the sub-element of the processor responding to the event are input into the execution function acquired from the execution function field as parameters.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210417546.8A CN102981821B (en) | 2012-10-26 | 2012-10-26 | A kind of event agent's method and system |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201210417546.8A CN102981821B (en) | 2012-10-26 | 2012-10-26 | A kind of event agent's method and system |
Publications (2)
Publication Number | Publication Date |
---|---|
CN102981821A CN102981821A (en) | 2013-03-20 |
CN102981821B true CN102981821B (en) | 2018-10-16 |
Family
ID=47855886
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201210417546.8A Active CN102981821B (en) | 2012-10-26 | 2012-10-26 | A kind of event agent's method and system |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN102981821B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN107203521B (en) * | 2016-03-16 | 2020-09-04 | 阿里巴巴集团控股有限公司 | Information processing method and device |
CN112199130B (en) * | 2020-10-14 | 2022-07-01 | 上海妙一生物科技有限公司 | Binding function execution method, device, equipment and storage medium |
CN113126992A (en) * | 2021-05-11 | 2021-07-16 | 南京炫佳网络科技有限公司 | Control element control method, device, equipment and storage medium |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7017162B2 (en) * | 2001-07-10 | 2006-03-21 | Microsoft Corporation | Application program interface for network software platform |
CN101551743A (en) * | 2008-03-31 | 2009-10-07 | 上海宝信软件股份有限公司 | Popup hidden-type data selecting container type control and realizing method thereof |
-
2012
- 2012-10-26 CN CN201210417546.8A patent/CN102981821B/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US7017162B2 (en) * | 2001-07-10 | 2006-03-21 | Microsoft Corporation | Application program interface for network software platform |
CN101551743A (en) * | 2008-03-31 | 2009-10-07 | 上海宝信软件股份有限公司 | Popup hidden-type data selecting container type control and realizing method thereof |
Non-Patent Citations (1)
Title |
---|
《YUI3学习(五)--- Event》;houfeng0923;《http://houfeng0923.iteye.com/blog/1126478》;20110728;正文第1-14页 * |
Also Published As
Publication number | Publication date |
---|---|
CN102981821A (en) | 2013-03-20 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US20250071167A1 (en) | Bidirectional mapping between applications and network content | |
US11520766B2 (en) | Event context enrichment | |
US11288142B2 (en) | Recovery strategy for a stream processing system | |
US8959119B2 (en) | Context-based graph-relational intersect derived database | |
CN109524070B (en) | Data processing method and device, electronic equipment and storage medium | |
US20170171143A1 (en) | Method and apparatus for unified message adaptation | |
WO2018103532A1 (en) | Monitoring method and related device free of burying-point deployment | |
US10838955B2 (en) | Systems and methods for metadata-driven command processor and structured program transfer protocol | |
CN104615748B (en) | Internet of Things Web event-handling methods based on Watir | |
CN104699706A (en) | Directory tree generation method, device and system | |
US20150213077A1 (en) | Method and system for causing a web application to obtain a database change | |
US20220350857A1 (en) | Methods and systems for browser extension used to generate relative xpath, absolute xpath and/or css selectors | |
US20150363493A1 (en) | Continuous collection of web api ecosystem data | |
CN106909361A (en) | Web development approaches and device based on masterplate engine | |
WO2018171572A1 (en) | Malicious web address identification method, computer apparatus and storage medium | |
RU2677563C2 (en) | Information display method, terminal and server | |
CN102981821B (en) | A kind of event agent's method and system | |
US20140053089A1 (en) | Identifying equivalent javascript events | |
CN111899087A (en) | Data providing method and device, electronic equipment and computer readable storage medium | |
CN108809770A (en) | A kind of resource monitoring method and system | |
JP6621444B2 (en) | Data generation method and apparatus based on inquiry content | |
CN111930377A (en) | Topological relation display method and device, server and storage medium | |
CA2900523A1 (en) | Systems and methods for metadata-driven command processor and structured program transfer protocol | |
CN115421693A (en) | Method and device for realizing micro front-end architecture, computer equipment and storage medium | |
CN114996043A (en) | Fault positioning method, device and equipment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
EXSB | Decision made by sipo to initiate substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |