Comment invoquer une méthode privée à partir d'une méthode publique et vice versa si je suis le plugin authoring guide?Appel de méthodes de plugin
Je déclare généralement les méthodes privées dans la méthode init
comme:
var methods = {
init: function(options) {
var settings = $.extend({
}, options);
return this.each(function() {
var $this = $(this);
var data = $this.data('griffin-editor');
this.trimSpaceInSelection = function() {
//how do I call a public method here?
//to get the this context correct.
}
if (typeof data !== 'undefined') {
return this;
}
//the rest of the code.
Il pourrait être la chose à faire incorrecte?
Pourquoi est-il différent avec le guide plugin? Cela pourrait aider http://stackoverflow.com/questions/6420825/call-private-method-from-public-method – elclanrs
@elclanrs: Voir ma mise à jour. – jgauffin
Je vois ... Je découvre des choses comme je vais. Ceux-ci pourraient aider, [1] (http://stefangabos.ro/jquery/jquery-plugin-boilerplate-revisited/), [2] (http://stackoverflow.com/questions/2061501/jquery-plugin-design- pattern-common-practice-for-dealing-with-private-functio), [3] (http://www.virgentech.com/blog/2009/10/building-object-oriented-jquery-plugin.html) – elclanrs