umdjs / umd

UMD (Universal Module Definition) patterns for JavaScript modules that work everywhere.
MIT License
7.42k stars 423 forks source link

myModule is not a function at HTMLDocument #62

Open Giulico opened 9 years ago

Giulico commented 9 years ago

hi everybody, I'm trying to use the "jqueryPluginCommonjs.js" for the first time and I'm using browserify to create the bundle for the browser. I wrapped a simple jquery plugin that I made (and tested) before, but I can't figure out why it works only if I specify the "browser" property within the package.json of my app:

"browser": {
  "fvalidation": "./node_modules/fvalidation/index.js"
},
"dependencies": {
  "fvalidation": "^0.1.1"
}

If I don't specify the browser field i get the error:

TypeError: $(...).fvalidation is not a function at HTMLDocument.

The module is here: https://github.com/Giulico/fValidation And in my app.js file I'm doning something like this

var fvalidation = require('fvalidation');
$(document).ready(function() {
  $('#myForm').fvalidation({
      onSubmit: function() { console.log('done!'); }
    });
});

I’m wondering if you might help me to understand what am I wrong. Thank you in advance Giulio