Requirejs-define jquery Quick Beginner Example (i)

Source: Internet
Author: User

Original address: http://6yang.net/articles_view.php?id=1103

2011-10-18 13:12:01 by "6yang", 1029 visits, Favorites | back

Example Description:

Demo[require]: http://6yang.net/myjavascriptlib/requirejs/demo/d1.html

Demo[require-define]: http://6yang.net/myjavascriptlib/requirejs/demo/d2.html

Demo[require-config]: http://6yang.net/myjavascriptlib/requirejs/demo/d3.html

Description under Require,require-define,require-config,app-bulid.js (introduction)

Require: The main tasks include asynchronous loading events and JS libraries.

Define: The primary task defines the event for easy invocation.

Require.config (): main task configuration related parameters.

App-bulid.js: The app-build.js is created for the Nodejs creation of the project used, the allocation directory.

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 strict//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >

<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title>requirejs Applications </title>

<style>
</style>
<body>

<!--<script src= "Js/jquery-1.6.2.min.js" ></script>-->
<script src= "Js/require.js" ></script>
<script>
Define ("Employee", function () {
You can name the This function here,
which can help in debuggers but
Have no impact on the module name.
return function Employee (first, last) {
This.first = First;
This.last = Last;
};
});

/*
Define ("main", ["employee"], function (employee) {
var john = new Employee ("John", "Smith");
alert (John.first);
});*/

/*
@ At this time the require includes the object variables defined in the Define and the loading JS file object.
The employee in the @ function (employee) is required to pass the parameter through the variables in the define;
*/

require (["Employee", "Js/test", "http://code.jquery.com/jquery-1.6.4.min.js"], function (employee) {
var john = new Employee ("John", "Smith");
Alert (John.first)
alert (objstu.country);
var inputval = $ ("Input:checkbox"). Prop ("name");
alert (inputval);
});


</script>

<div id= "dic" >sssssssssssss</div>
User name: <input type= "text" name= "username" value= "1244555"/><br/>
Gender: <input type= "checkbox" name= "Sex" value= "0"/>
</body>

share to:0 I want to comment this article from: http://www.6yang.net/articles_view.php?id=1103

Requirejs-define jquery Quick Beginner Example (i)

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.