Skip to content

Commit

Permalink
Explicitly require jquery in kanso. Fixes kanso#12.
Browse files Browse the repository at this point in the history
The jquery dependency is now explicitly included through require.
  • Loading branch information
mgmarino committed Oct 6, 2014
1 parent 66c3b45 commit 02d3971
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Add `db` to your dependencies section in `kanso.json`.

> run `kanso install` to fetch the package
You also need __jQuery__ to be included on your page, since this module uses
jQuery.ajax to make requests.


### Events

The db module is an EventEmitter. See the
Expand Down
11 changes: 6 additions & 5 deletions db.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@


var events = require('events'),
_ = require('underscore')._;
_ = require('underscore')._,
jQuery = require('jquery');


/**
Expand Down Expand Up @@ -62,17 +63,17 @@ var httpData = function (xhr, type, s) {
data = xml ? xhr.responseXML : xhr.responseText;

if (xml && data.documentElement.nodeName === "parsererror") {
$.error("parsererror");
jQuery.error("parsererror");
}
if (s && s.dataFilter) {
data = s.dataFilter(data, type);
}
if (typeof data === "string") {
if (type === "json" || !type && ct.indexOf("json") >= 0) {
data = $.parseJSON(data);
data = jQuery.parseJSON(data);
}
else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
$.globalEval(data);
jQuery.globalEval(data);
}
}
return data;
Expand Down Expand Up @@ -257,7 +258,7 @@ exports.stringifyQuery = function (query) {
exports.request = function (options, callback) {
options.complete = onComplete(options, callback);
options.dataType = 'json';
$.ajax(options);
jQuery.ajax(options);
};


Expand Down
3 changes: 2 additions & 1 deletion kanso.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dependencies": {
"modules": null,
"underscore": ">=1.1.5",
"events": null
"events": null,
"jquery": null
}
}

0 comments on commit 02d3971

Please sign in to comment.