Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on Plugin Jquery - Autocomplete #65

Closed
globsecure opened this issue Oct 21, 2014 · 3 comments
Closed

Error on Plugin Jquery - Autocomplete #65

globsecure opened this issue Oct 21, 2014 · 3 comments

Comments

@globsecure
Copy link

I'm creating an autocomplete in my app, however I am having difficulty with the integration of jQuery.
Error on:

[App "Portodesign"] TypeError: undefined is not a function
at Object.module.exports.globServiceAutoComplete (http://localhost:4567/app.js:44:38)
at AppSubclass.source.principalController (http://localhost:4567/app.js:196:31)
at AppSubclass.

portodesign - cdesenvolvimentoservidoresxamppxampphtdocsdemo_apps-masterportodesign - app js - webstorm 8 0 1

@svizzari
Copy link

Hi @globsecure, in your module you're referring to a jQuery global jQuery. This global is not available in an App. You could possibly make your module export a function and then pass an argument to that function when requiring the module into your App. The argument you would pass would be reference to jQuery as it exists in your App.

Something like:

// module-a.js
module.exports = function(jQuery) {
  return {
    globServiceAutocomplete: function() {
      // Do some things with jQuery
      jQuery('.some-class').val();
    }
  };
}
// app.js
events: {
  'app.created': 'init'
},
init: function() {
  var modA = require('module-a.js')(this.$);
}

It is important to note here that the version of jQuery you would pass from the app would be scoped to the app's own DOM.

@globsecure
Copy link
Author

Perfect!

I was not calling the Jquery!

Another question is how to get the DOM of an input in the PLUGIN.

        thisElement.attr("autocomplete", "off");
        console.log(thisElement.attr("name"));

        thisElement.keyup(function (ev) {
            var getOptions = { query: thisElement.val() }

Thank you!

@globsecure
Copy link
Author

I am very noob! Problem was the calling function before loading the template!

Very very thanks!!!!

[close] 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants