Add jquery and seajsjquery to seajs 2.3.0
[Preface]
The previous article briefly introduced the use of seajs. In the afternoon, I encountered a problem when using seajs to integrate jquery.
Download examples from seajs, and directly require ('jquery ') has no problem,
I wrote it again, but I reported that $ is not defined ..
Find this blog to solve the problem:
Http://blog.csdn.net/adeyi/article/details/18003043
Thank you very much.
[Reason]
Js in seajs is a module that loads jquery directly. This jquery is not modularized,
Yes, jquery in examples is modular ..
[Solution]
Write a jquery. js file by yourself. The Code is as follows:
That is, copy the jquery source code and add a return
[Example]
Page:
<! DOCTYPE html> Js:
define(function(require, exports, module) {var $ = require('jquery');var s = $('#test').attr('data');alert(s);});
Effect:
Well, seajs of the potholes does not have a pdf document. It is a bit east and west...
How does seajs call the jquery plug-in?
I have asked the author of seajs, yuber's predecessors, to rewrite this question. The plug-in cannot pollute jquery's $ or $. fn. Otherwise, repeated calls may occur.
Failed to load jquery due to seajs issues
Seajs needs to transform jquery because native jquery does not provide interfaces to it. We recommend that you use AMD requireJS.