English 中文(简体)
• 如何将分类方法排在单体外
原标题:how can i call method of class outiside the class javascript
  • 时间:2010-09-22 09:14:36
  •  标签:
  • javascript
var Card = YClass.extend({
 // define Class Name
 className: Card , 
 // class level default options
 config:{
  id: cardid , 
  container: body ,   // id of container in which to render the user
  render:false,
  template:  tmpl_card ,  // id of template used to render user
  debug:false   
 },
setposition:function() {
  var i=1;
  var xpos=10;
  var ypos=15;
  var recvflag=false;
}
);

• 如何确定职位职能,一是用卡盘(Card.setposition)进行审判;

but its giving me error that setposition is not defined why??

最佳回答

这实际上不是一件大事,而是一件大事。 我不知道YClas是什么,但我的猜测是它界定了states,然后由你来做instances:

var c = new Card();
c.setposition();

这与Resig s“Sim Javaple/a>。 Prototype s 编码 Object,或系统I rel=“nofollow noreferer”>>>。

如果你只想一个有某些功能的集装箱,你就能够直接做到:

var Card = {
    setposition: function() {
        alert("Hi there!");
    };
};
Card.setposition(); // alerts "Hi there!"

......我猜想你出于某种原因重新使用YClass。

问题回答

阁下:

Card.prototype.setPosition();

<><0>WHY:

印章: 储存在Class。 反对。 当Class 创建时,本例具有Classprototype上的财产。 反对。 这意味着请Class.prototype.method在您打电话instance.method, 它自己没有。 如果你想要立即使用Class的方法,你应直接引用prototype。 反对。





相关问题
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.