Skip to content

Commit

Permalink
Abstracted namespace to variable
Browse files Browse the repository at this point in the history
  • Loading branch information
chedaroo committed Oct 19, 2017
1 parent a5451e2 commit df2aed4
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions google-places.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
(function($) {

$.googlePlaces = function(element, options) {

var defaults = {

var namespace = 'googlePlaces',
defaults = {
placeId: 'ChIJN1t_tDeuEmsRUsoyG83frY4' // placeId provided by google api documentation
, render: ['reviews']
, min_rating: 0
Expand Down Expand Up @@ -50,7 +51,7 @@
plugin.place_data = place;

// Trigger event before render
$element.trigger('beforeRender.googlePlaces');
$element.trigger('beforeRender.' + namespace);

// render specified sections
if(plugin.settings.render.indexOf('reviews') > -1){
Expand Down Expand Up @@ -91,7 +92,7 @@
);

// Trigger event after render
$element.trigger('afterRender.googlePlaces');
$element.trigger('afterRender.' + namespace);

});
}
Expand Down Expand Up @@ -272,9 +273,9 @@
$.fn.googlePlaces = function(options) {

return this.each(function() {
if (undefined == $(this).data('googlePlaces')) {
if (undefined == $(this).data(namespace)) {
var plugin = new $.googlePlaces(this, options);
$(this).data('googlePlaces', plugin);
$(this).data(namespace, plugin);
}
});

Expand Down

2 comments on commit df2aed4

@JeremyOB
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

with this commit, I get this error in chrome console.

google-places.js:
276 Uncaught ReferenceError: namespace is not defined
at HTMLDivElement. (google-places.js:276)
at Function.each (jquery-2.2.4.min.js:2)
at n.fn.init.each (jquery-2.2.4.min.js:2)
at n.fn.init.$.fn.googlePlaces (google-places.js:275)
at HTMLDocument. ((index):136)
at i (jquery-2.2.4.min.js:2)
at Object.fireWith [as resolveWith] (jquery-2.2.4.min.js:2)
at Function.ready (jquery-2.2.4.min.js:2)
at HTMLDocument.J (jquery-2.2.4.min.js:2)

@leegellie
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm getting the same error as @JeremyOB, Please help.

Please sign in to comment.