OOP in javascript with callbacks

I want to close my window (just a div with position absolute that is draggable) when I click on the close link This is my code function ApplicationWindow() { this.window = $('
'); this.create = function create() { //..... var closeButton = this.window.find('.close'); closeButton.live('click', this.close); } this.close = function close() { this.window.fadeOut(200); }; } When I click on the close button the close function is executed, but the problem is that I get an error "this.window is undefined". That is because the close function is passed as a callback I think, but my question is how I can solve this on a nice way?

以上就是OOP in javascript with callbacks的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » JavaScript 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准