I've been looking all over the place and I can't find what this is:

updateCallback : function(elm, status) {
    if (typeof elm.callbackFunction != 'undefined') {

What is callbackFunction? How come I can't find it defined anywhere?


It's a function that is passed into this script from another place in the script. This function is executed here with the ID and status given as arguments. The function it self will be anonymous or have a different name most likely

  • i see it being used like $('option_36_1').callbackFunction = validateOptionsCallback; It's a function being called on an element but how can it be called if it doesn't exist. Is it a variable or keyword? Can it be called anything then, like $(...).myrandomtext = validateOptionsCallback
    – jstrez77
    Mar 8 '13 at 20:48
  • jQuery does allow you to attach pretty much anything to an object. but in this case you first attach the object 'callbackFunction' by doing $('option_36_1').callbackFunction = validateOptionsCallback and then later on validateOptionsCallback is executed in the code by calling elm.callbackFunction()
    – Sander Mangel
    Mar 8 '13 at 21:04
  • so is this how you call class methods with javascript/jquery then? Like a function prototype. I'm not used to that.
    – jstrez77
    Mar 8 '13 at 21:31
  • I think Magento uses Prototype and it appears that is how you define a new method. I see this example: Pirate.allHandsOnDeck = function(n) {..}
    – jstrez77
    Mar 8 '13 at 21:38
  • you're right, it's prototype... sorry for that :) Im not too good with prototype to be honest but as far as I know you can attach anything you want to the main variable ($). Hope I helped you somewhat. Im more into PHP then javascript
    – Sander Mangel
    Mar 8 '13 at 21:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.