Ticket #11803 (closed bug: invalid)
IE7: Scope Binding inside Click Event
| Reported by: | stefanteofanovic@… | Owned by: | stefanteofanovic@… |
|---|---|---|---|
| Priority: | undecided | Milestone: | None |
| Component: | unfiled | Version: | 1.7.2 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
Hello,
Am having a class structured like this:
sClassName = function(par1, par2) {
this.init(par1, par2);
}
$.extend(sClassName.prototype, {
init: function(par1, par2){
doing something...
}, theFunction: function(){
doing something...
}, addEvent: function(){
$('somedomelement').click('click', function(){
this.theFunction();
}.bind(this)); <- binding the scope
} ...
binding the scope "}.bind(this));" is working in FF and Chrome. My click event has scope over the instance which means i can call the function theFunction() from inside the click event.
How can i do this for IE7?
My class is manipulating the complexe object collections and not only DOM element. I need to have access to my functions from inside the click event. using "windows.classname.prototype.theFunction()..." may not work for multiple object instances.
Please help me
Regards,
Teofanovic Stefan
Change History
comment:1 Changed 12 months ago by rwaldron
- Owner set to stefanteofanovic@…
- Status changed from new to pending
comment:2 Changed 12 months ago by stefanteofanovic@…
- Status changed from pending to new
Hello,
Thanks for your prompt answer. That looks like an interesting tool.
As requested i have created a small test case: http://jsfiddle.net/FrKyN/323/
This works on latest IE, FF and Chrome. Today i had problem with it using IE7 and i cant tell you if it works in here i a dont have IE7 installed at home.
Please follow the bug reporting guidlines and use jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

Thanks for taking the time to contribute to the jQuery project! Please provide a complete reduced test case on jsFiddle to help us assess your ticket!
Additionally, be sure to test against the "jQuery (edge)" version to ensure the issue still exists. To get you started, use this boilerplate: http://jsfiddle.net/FrKyN/ Open the link and click to "Fork" (in the top menu) to begin.