Q:

Passing a var from one Extended function to another

I am having trouble passing the url of $.PhotoUpdater.doUpdate(url) to do the doUpdate function. 
Firefox returns this error :
useless setTimeout call (missing quotes around argument?)
[Break on this error] timer = setTimeout($.PhotoUpdater.doUpdate(url), 5000) 

my code:
$.extend({
  PhotoUpdater: {

    startUpdate: function(organization, gallery){
      url = "/organizations/" + organization + "/media/galleries/" + gallery + "/edit_photo_captions"
      timer = setTimeout($.PhotoUpdater.doUpdate(url), 5000)
    },
    stopUpdate: function(){
      clearTimeout(timer);
      timer = 0;
    },
    doUpdate: function(url){
      $.ajax({type: "GET", url: url, dataType: "script"});
    }
  }
});

How I call it:
$.PhotoUpdater.startUpdate("#{@organization.id}", "#{@gallery.id}");

A:

You need to pass a function into window.setTimeout, not the result of calling a function:
startUpdate: function(organization, gallery){
    url = "/organizations/" + organization + "/media/galleries/" + gallery + "/edit_photo_captions";
    timer = window.setTimeout(function() {
        $.PhotoUpdater.doUpdate(url)
    }, 5000);
},

