最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - ReferenceError: define is not defined while embedding fuelux in datagrid.js - Stack Overflow

programmeradmin0浏览0评论

I wanted to add use / to build a datagrid. I wanted to add the library to use it. I did the following:

<link href="<spring:url value='/assets/css/fuelux.min.css' htmlEscape='true' />"      media="all" rel="stylesheet" type="text/css" />
<link href="<spring:url value='/assets/css/fuelux-responsive.min.css' htmlEscape='true' />" media="all" rel="stylesheet" type="text/css" />
<script src="<spring:url value='/assets/js/fuelux-datagrid.js' htmlEscape='true' />" type="text/javascript"></script>

I am sure that the path are correct because they work in other libraries. However, I get following error:

ReferenceError: define is not defined
[Break On This Error] 
define(['require','jquery'],function(require) {

where define(['require','jquery'],function(require) {... is code in fuelux-datagrid.js.

  • What is this error?
  • I think define is a keyword of require.js. Does this mean fuelux-datagrid has dependency on require.js?
  • Can anybody explain me how to load the library so to make it work?

I wanted to add use http://exacttarget.github.com/fuelux/ to build a datagrid. I wanted to add the library to use it. I did the following:

<link href="<spring:url value='/assets/css/fuelux.min.css' htmlEscape='true' />"      media="all" rel="stylesheet" type="text/css" />
<link href="<spring:url value='/assets/css/fuelux-responsive.min.css' htmlEscape='true' />" media="all" rel="stylesheet" type="text/css" />
<script src="<spring:url value='/assets/js/fuelux-datagrid.js' htmlEscape='true' />" type="text/javascript"></script>

I am sure that the path are correct because they work in other libraries. However, I get following error:

ReferenceError: define is not defined
[Break On This Error] 
define(['require','jquery'],function(require) {

where define(['require','jquery'],function(require) {... is code in fuelux-datagrid.js.

  • What is this error?
  • I think define is a keyword of require.js. Does this mean fuelux-datagrid has dependency on require.js?
  • Can anybody explain me how to load the library so to make it work?
Share Improve this question edited Oct 14, 2014 at 23:22 superjos 12.7k6 gold badges94 silver badges141 bronze badges asked Mar 29, 2013 at 12:36 LasangLasang 1,3796 gold badges24 silver badges44 bronze badges
Add a comment  | 

3 Answers 3

Reset to default 12

This worked for me:

<script src="https://raw.github.com/ExactTarget/fuelux/master/lib/require.js"></script>
<script type="text/javascript" src="https://raw.github.com/ExactTarget/fuelux/master/dist/datagrid.js"></script>

I tried what @AdamAlexander suggested and what is suggested here and didn't work. I also tried the latest requiredjs and got a nasty exception. Go figure.

If you are not using RequireJS you can get around this by loading just the loader.min.js in a basic script tag:

<script src="http://fuelcdn.com/fuelux/2.3/loader.min.js"></script>

This package contains all of the JavaScript needed for Bootstrap and Fuel UX, with no external dependency on an AMD loader.

Yes, they seem to have a dependency on RequireJS. I must agree they don't have much resources that explains how to load the library (at least from what I saw), but what I would do is load require.js and check what other resources it is trying to load afterwards, by looking at the network requests.

Here's an example on how to setup RequireJS. You can also look at their docs.

<script src="scripts/require.js"></script>
<script>
  require.config({
    baseUrl: "/another/path", //here's where it will look for scripts
    paths: {
        "some": "some/v1.0" //path to other dependencies not located in the base path
    }
  });
</script>
发布评论

评论列表(0)

  1. 暂无评论