Comments (4)
Absolutely that works - but my question is - can it be shortened and made less verbose? I want datatables.net-bs
to include the DataTables Bootstrap integration for the CSS and the JS with a since call, since one without the other is more or less redundant.
As I noted in my original post, this is absolutely possible already, but I'm looking to see if @guybedford knows if there is a cleaner approach.
from require-css.
I would start by trying with local copies, for example using bower to forget about manually updating the dependencies. Since there isn't a way to know for sure when a CSS stylesheet is done loading, you're asking too much.
Second, you might want to look at normalize.js to see how the plugin deals with protocol relative urls and fallback paths.
Third, the deps property shouldn't be parallel to paths. At least the way I config my apps, deps is a property of each module under the shims config.
from require-css.
Thanks for the reply.
Since there isn't a way to know for sure when a CSS stylesheet is done loading
My understanding of what this plug-in for requirejs does is exactly that - from the readme: "Allows the construction of scripts that can require CSS"
Second, you might want to look at normalize.js to see how the plugin deals with protocol relative urls and fallback paths.
Thank you I will. I'm not sure how that will help with using require-css!
in the paths, but it might point to how a plug-in can be used to operate on the path.
Third, the deps property shouldn't be parallel to paths
The requirejs docs state that the config.deps
option can be used to require a module immediately, which is what I used it for above. It could equally be in the require
line, but I just put it in the deps
config for simplicity.
from require-css.
This one worked for me
requirejs.config({
paths: {
"require-css": "//cdnjs.cloudflare.com/ajax/libs/require-css/0.1.8/css.min",
"jquery": "//code.jquery.com/jquery-2.1.4.min",
"bootstrap": "//cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min",
"datatables.net": "//nightly.datatables.net/js/jquery.dataTables.min",
"datatables.net-bs-js": "//nightly.datatables.net/js/dataTables.bootstrap.min",
"datatables.net-bs-style": "//nightly.datatables.net/css/dataTables.bootstrap.min"
}
});
define([
"jquery",
"datatables.net",
"datatables.net-bs-js",
"require-css!bootstrap",
"require-css!datatables.net-bs-style"
], function (jQuery) {
jQuery(document).ready(function () {
jQuery('#myTable').DataTable();
});
});
from require-css.
Related Issues (20)
- explanation requested
- In IE8-9 onload does not fire in the second iframe HOT 1
- [Help!]There is a problem that load the css in iframe
- Is it possible to set media type when I load css via require?
- Not working relative path's with baseUrl HOT 2
- How to skip css! references in r.js builds? HOT 1
- Removing CSS files (by reading the `removeCombined` property) HOT 3
- R.js build fails with external resources defined in the "paths" config property HOT 8
- req.toUrl is undefined HOT 2
- IE9: ieCurCallback null, Object expected HOT 1
- Error load timeout for css modules HOT 2
- In css-builder.js path.dirname(config.out) got an error HOT 2
- having trouble specifying path of css to load HOT 1
- R.js - Path must be a string HOT 4
- "Script-inlined CSS Benefits" - additional info
- how to work with commonjs module HOT 1
- When loading a cdn style sheet fails,How to load a local style sheet
- require-css load css file folder name conflict with plugin name
- Loading a css file that doesn't end with ".css"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from require-css.