ember-addons / bootstrap-for-ember

Bootstrap for Ember.js
http://ember-addons.github.io/bootstrap-for-ember
Apache License 2.0
704 stars 103 forks source link

Import Syntax For Bootstrap For Ember #142

Closed agentVargas2012R closed 10 years ago

agentVargas2012R commented 10 years ago

Hello Bootstrap-for-ember Team,

First off, I love this framework, its excellent!

All I'm trying to figure out at this point is the correct syntax for importing Bootstrap into my javascript file.

JSHint is having a fit about that.

Any help would be much appreciated!

smcclstocks commented 10 years ago

here here

digitalbreed commented 10 years ago

I tried two approaches which both worked fine for me.

  1. Mark Bootstrap as global at the beginning of the JS file (useful if you're using it just once or twice): /* global Bootstrap */
  2. Add Bootstrap as a predefined variable to your .jshintrc file:
{
    "predef": {
        "document": true,
        "window": true,
        "location": true,
        "setTimeout": true,
        "Ember": true,
        "Em": true,
        "DS": true,
        "$": true,
        "Bootstrap": true
    },
    ...

Ember App Kit / Ember CLI do it that way for Ember, $, etc., so I don't see a reason why we shouldn't do it like that for Bootstrap.

fmendez commented 10 years ago

I'm currently having the same issue, but the proposed solutions are not working for me:

Error:

Uncaught ReferenceError: Bootstrap is not defined vendor.js:75177
(anonymous function) vendor.js:75177
(anonymous function)

Specific line:

screen shot 2014-07-29 at 4 12 00 pm

.jshintrc:

{
  "predef": {
    "document": true,
    "window": true,
    "Bootstrap": true,
    "NetWorthENV": true
  },
  "browser" : true,
  "boss" : true,
  "curly": true,
  "debug": false,
  "devel": true,
  "eqeqeq": true,
  "evil": true,
  "forin": false,
  "immed": false,
  "laxbreak": false,
  "newcap": true,
  "noarg": true,
  "noempty": false,
  "nonew": false,
  "nomen": false,
  "onevar": false,
  "plusplus": false,
  "regexp": false,
  "undef": true,
  "sub": true,
  "strict": false,
  "white": false,
  "eqnull": true,
  "esnext": true,
  "unused": true
}

Brocfile:

/* global require, module */

var EmberApp = require('ember-cli/lib/broccoli/ember-app');
var app = new EmberApp();

app.import('vendor/moment/moment.js');
app.import('vendor/bootstrap/dist/css/bootstrap.css');

var bsPath = 'vendor/ember-addons.bs_for_ember/dist/js/';
[
  'bs-basic',
  'bs-core',
  'bs-alert'
].forEach(function(file){
  app.import(bsPath + file + '.min.js');
});
module.exports = app.toTree();

Ember-CLI: version: 0.0.40

@agentVargas2012R Did the solution proposed above worked for you?

fmendez commented 10 years ago

ahh never-mind, I had the wrong order while including the files (bs-core wasn't the first inclusion).