st_clair_clarke
st_clair_clarke

Reputation: 5705

JQuery package for Dart

I would like to use JQuery in Dart, but the only package I found ishttps://pub.dartlang.org/packages/jquery. However, on attampting to run the application I received the following console output

Uncaught ReferenceError: jQuery is not defined
  (anonymous function)

This suggest that jQuery cannot be found. Does anyone knows any other means for me to introduce jQuery so it can be found.

PS: I am trying to get jQuery so I can use Semantic UI (http://semantic-ui.com/introduction/getting-started.html)

Thanks

Upvotes: 0

Views: 358

Answers (2)

Argenti Apparatus
Argenti Apparatus

Reputation: 4013

I'm sure you will be questioned about why you want to use JQuery in a Dart project, but to answer the question asked.

Presumably you have the following in your pubspec.yaml:

dependencies:
  jquery: "^1.0.1"

If you reference jquery.js like this

<script src="packages/jquery/jquery.js"></script>

in your HTML it should find the js file as jquery.js is in build/web/packages after pub build is run.

I'm rather suspicious of that jquery package. It appears to merely be a wrapper around a copy of the jquery.js file. I'm not sure if it was really created by the JQuery team. (I have not investigated the uploader though.)

I looked at the sample project referenced in the Dart js package to see how they include a JS library. The index.html file contains:

<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/1.0.2/Chart.js"></script>

Chart.js is being referenced from its distribution source.

I'm guessing that wrapping a JS library in a pub package is so that a dependency on it can be declared explicitly. I don't know if wrapping JS libraries in pub packages in this way is a widespread practice.

Upvotes: 1

Randal Schwartz
Randal Schwartz

Reputation: 44046

Just an aside, but I started using semantic a year ago, and I regret ever having chosen it. If you use precisely the sequence of HTML that they show, it's great. But you cannot be creative. Any mix of anything requires tons of tweaking or trial and error.

Bootstrap would probably be far more effective for your time.

Upvotes: 0

Related Questions