0

Hello

I have this similar code:

var SomeVar = Class.create({
    one: null,
    two: null,
    three: null,

initialize: function(one, two) {
        this.one = one;
        this.two = two;

    },

startListeners: function() {


        $j('#somediv1').mousedown(function(e) {


        this.three=3;
        three="hi"



        }.bind(this));


    $j('#somediv2').mousedown(function(e) {


        console.log(this.three);
        console.log(three);



        }.bind(this));
    },

});

As you see there are more can one variable called "three". What is the best way to have one common variable named three where I can modifiy it freely and it does not get deleted/destroyed everytime I do a mousedown on divone then on divtwo it comes out null.

It may be related but what the hell is "}.bind(this));"?

2
Contributors
2
Replies
21
Views
4 Years
Discussion Span
Last Post by riahc3
0

What is the best way to have one common variable named three where I can modifiy it freely and it does not get deleted/destroyed everytime I do a mousedown on divone then on divtwo it comes out null.

I don't think you can.

The only way is a workaround that you can change from one to two to three and so forward.

I also don't think there a work around either.

You can look at this:

https://gist.github.com/hallettj/64478

0

There has to be a workaround.

Ive come up with a solution anyhow.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.