diff --git a/README.md b/README.md index bd36c50d..728763fb 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,20 @@ Run `grunt test` to run jsHint and the Mocha test suite. Run `grunt list_modules` to get the list of available plugins and languages. +### AMD importing +To import this into require.js you need to set the microevent and extendext folders and set them as dependencies in your AMD file. For example, like this: + + paths: { + "microevent": "../bower_components/microevent-mistic100/microevent", + "extendext": "../bower_components/jquery-extendext/jQuery.extendext", + }, + shim: { + jquery: { + exports: "jQuery" + }, + jquerybuilder: ["jquery", "microevent", "extendext"] + } + ### Contributing Changes have to be done only in `src` directory. The `dist` directory is updated only once in a while before a release. diff --git a/src/query-builder.js b/src/query-builder.js index 262e851c..3d0119f6 100644 --- a/src/query-builder.js +++ b/src/query-builder.js @@ -43,6 +43,10 @@ this.init(options); }; + //Added this to make it work in AMD + if(!!define && typeof define == "function" && !!define.amd){ + var MicroEvent = require("microevent"); + } MicroEvent.mixin(QueryBuilder); @@ -1122,7 +1126,7 @@ $target.addClass('has-error'); var $error = $target.find('.error-container').eq(0); - $error.attr('title', fmt.apply(null, errorLoc)); + $error.attr('title', fmt.call(null, "Error at {0}", errorLoc)); } this.trigger('validationError', $target, error); @@ -1709,4 +1713,4 @@ }); } -}(jQuery)); \ No newline at end of file +}(jQuery));