Advertisement
Guest User

Untitled

a guest
Mar 5th, 2015
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. define(function() {
  2. // Configuration of RequireJS
  3. requirejs.config({
  4. // No module can start with require. This can potentially allow easier definition of some elements
  5. enforceDefine : true,
  6.  
  7. map : {
  8. '*': {
  9. 'jquery': 'libs/jquery',
  10. },
  11.  
  12. // To make jquery work with requireJS: see http://requirejs.org/docs/jquery.html
  13. // 'jquery' wants the real jQuery module
  14. // though. If this line was not here, there would
  15. // be an unresolvable cyclic dependency.
  16. 'libs/jquery': { 'jquery': 'jquery' },
  17. },
  18.  
  19. // The base URL is just the top-level directory where the files are stored
  20. baseUrl : './',
  21.  
  22. // Kick-start the application by loading these files
  23. deps : [ 'MyMainPanel' ],
  24. });
  25. });
  26.  
  27. define(['jquery'], function (jq) {
  28. return jq.noConflict( true );
  29. });
  30.  
  31. ...
  32. <dependency>
  33. <groupId>org.webjars</groupId>
  34. <artifactId>jquery</artifactId>
  35. <version>${jquery.version}</version>
  36. </dependency>
  37. ...
  38.  
  39. GET http://localhost:8080/jquery.js 404 (Not Found)
  40. require.js:166 Uncaught Error: Script error for: jquery
  41. http://requirejs.org/docs/errors.html#scripterror
  42.  
  43. define(['ractive',
  44. 'jquery',
  45. function(Ractive,
  46. $,
  47. ){
  48. var Panel = Ractive.extend({
  49. el:"mainPanel",
  50.  
  51. oninit: function(){
  52. $.ajax({url: "/myURL"}).done(function(types){
  53. // Work
  54. })
  55. }
  56. })
  57.  
  58. return Panel
  59. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement