"Notes" JavaScript Coding specification-Events & Modules

Source: Internet
Author: User

When attaching data on an event object (whether it is a DOM event or a private event that is owned like backbone), the hash object should be passed instead of the original value, which allows subsequent contributors to add more data to the event object without having to find or update each event handler. For a chestnut, do not use the following method:

bad$ (this). Trigger (' listingupdated ', listing.id), ... $ (this). On (' listingupdated ', function (e, listingid) {//Do Something with Listingid});

should be as follows:
good$ (this). Trigger (' listingupdated ', {listingId:listing.id}), ... $ (this). On (' listingupdated ', function (e, data) {//do something with Data.listingid});

The module should be! To begin, this ensures that when the script is connected, if the malformed module forgets to import, including the last semicolon, it will not produce an error. Explanation

The file should be named Camel, placed in a folder of the same name, and the name of the single exit matches

Define a Noconflict () method to set the previous version of the Export module and return the current version.

At the top of the module, declare ' use strict ';

Fancyinput/fancyinput.js!function (Global) {' Use strict '; var previousfancyinput = Global. Fancyinput;function fancyinput (options) {this.options = Options | | {};} Fancyinput.noconflict = function noconflict () {Global. Fancyinput = Previousfancyinput;return fancyinput;}; Global. Fancyinput = Fancyinput;} (this);

Genesis 1:18 and rule over the day and over the night,and to divide the light from the Darkness:and of God saw that it's was go Od.

"Notes" JavaScript Coding specification-Events & Modules

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.