1

I am doing the following:

elemDrop: function(elem) {
    return elem;
},

elemAddRel: function(json) {

    var elem = this.elemDrop;

    console.log(elem);

    $(elem.item[0]).addClass('showTab').attr('rel', json.pageId);

},

However when i console.log 'elem', it just stores the entire function into a variable. How can i actually store the result of the function into the variable?

3
  • didn't you mean this.elemDrop? Commented Jan 23, 2012 at 14:48
  • Please post the entire object code that these two functions are part of. this.chuckDrop could be initialized somewhere else in the said object. Commented Jan 23, 2012 at 14:48
  • I think your code snippet is wrong. Is this.chunkDrop a reference to this.elemDrop? Commented Jan 23, 2012 at 14:50

2 Answers 2

2

You should be able to do:

var elem = this.chunkDrop();

The use of the brackets () will trigger the function and return the result rather than setting the variable equal to the function itself.

Sign up to request clarification or add additional context in comments.

Comments

0

So you need to execute the function by this.chunkDrop();

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.