0

$.PhotoUpdater.doUpdate(url)関数を実行するためにの URL を渡すのに問題がありdoUpdateます。

Firefox は次のエラーを返します。

useless setTimeout call (missing quotes around argument?)
[Break on this error] timer = setTimeout($.PhotoUpdater.doUpdate(url), 5000) 

私のコード:

$.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"});
    }
  }
});

私はそれをどのように呼びますか:

$.PhotoUpdater.startUpdate("#{@organization.id}", "#{@gallery.id}");
4

1 に答える 1

3

window.setTimeout関数を呼び出した結果ではなく、に関数を渡す必要があります。

startUpdate: function(organization, gallery){
    url = "/organizations/" + organization + "/media/galleries/" + gallery + "/edit_photo_captions";
    timer = window.setTimeout(function() {
        $.PhotoUpdater.doUpdate(url)
    }, 5000);
},
于 2010-09-30T17:23:29.397 に答える