[jQuery] Plugin scope for methods and 'this'
Hi folks,
Thanks you some of you already on IRC who have helped me with this,
but I've got to a point where I'm hitting a brick wall with my plugin.
Let me just explain it first.
Google Map Application (gmapp) is my first plugin for jQuery, and aims
to provide a fully functional application in jQuery for interactive
with Google Map and Geocoder API. What I am trying to do is make is
as generic as possible, although the plugin is initially being
designed for my own CakePHP-powered application.
With the current version here: http://pastebin.ca/614176 I am trying
to make both the Google GMap2 and GClientGeocoder objects available to
the user. However, I am not having any luck. At the moment I have 2
main errors:
1) in a page where I return one or more points from the database, I
would like to be able to do this:
$('#gmap').gmapp();
$('#gmap').GMap2().setCenter(new GLatLng(55.899956, -3.087158));
However, with the way I currently have the code, I get an error that
$('#gmap').GMap2() is not a function. So it does not seem to be
getting returned.
2) Before, I was creating the geocoder by doing:
var geocoder = new GClientGeocoder();
I then passed this geocoder into the method searchAddress, which
worked fine. But now I'd like to make the object global by making it
available through this.GGeocoder. In my code, I have tested it in the
console, and it appears the initial GGeocoder is being initialised,
but when i then try and do an address search, I get the error:
this.GGeocoder has no properties; This is at the first line inside the
searchAddress method.
Now, ANY help on either of these matters would be appreciated. I've
read over the jQuery plugin docs, and had a look inside a couple of
plugins, but so far nothing has jumped out at me how to fix these
errors.
--
Tane Piper
http://digitalspaghetti.tooum.net
This email is: [ ] blogable [ x ] ask first [ ] private