English 中文(简体)
从子功能中挑选出来的人?
原标题:Access to selector from sub function?

让我说一下,我创造了这一gin:


$.fn.my_namespace = function() {}

a. 具备1级职能:

$.fn.my_namespace.category_func = function() {}

二级职能(实际应用):

$.fn.my_namespace.category_func.app_func() {
   alert(this);
   alert(this.selector);
}

执行:

$( div ).my_namespace.category_func.app_func();

我现在怎么能够把实际的遴选人调回? 在这种情况下,这似乎是母体功能(efunc类),而不是 j子。

如何? 我如何从旁听“func()”?

问题回答

j Querys fn namespace is used to hold Functions which.1/63/ acode.j 标注/.

你们只能在那里投下一个新的目标,期望一切照样工作。

我先回答这一点,但我看不到。 http://www.un.org/Depts/DGACM/index_french.htm 在这种情况下,你将<代码>-func作为该标的,并打电话app_func()

基金会使用的模式是解决这一问题的一种可能方式。 它们允许你通过诸如<条码> 贵重(销毁);等做事,把方法上调。

moment:

$.fn.my_namespace = function(submethod, method) {
  var args = [].slice.call(arguments, 1);
  var func = $.fn.my_namespace[submethod];
  if (func && method) {
    if ($.isFunction(func[method])) {
      args.shift(); // remove the method 
      func = func[method];
    }
  }
  if ($.isFunction(func)) { 
    // using .apply() allows us to pass `this` along to our "method functions"
    return func.apply(this, args);
  } else {
    // didn t find the method, return... or do something else...
    console.log( my_namespace , this, arguments);
    return this; // jQuery chaining default
  }
}

$.fn.my_namespace.category_func = function() {
   console.log( category_func , this, arguments);
   return this;
}
$.fn.my_namespace.category_func.method_func = function() {
   console.log( method_func , this, arguments);
   return this;
}

$("body").my_namespace( category_func ,  method_func , 10);
//method_func jQuery(body) [10]
$("body").my_namespace( category_func , 10);
//category_func jQuery(body) [10]
$("body").my_namespace(10,  slow );
//my_namespace jQuery(body) [10, "slow"]




相关问题
selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

How to fire event handlers on the link using javascript

I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Clipboard access using Javascript - sans Flash?

Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...

javascript debugging question

I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...

Parsing date like twitter

I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.

热门标签