我想創建一個動作數組。基本上這些是知道接下來要觸發的函數的函數列表。我嘗試了很多方法,但無法讓他們可靠地工作。我做的GUI和有彈出框是回調時,他們已經完成了自己的工作(選擇文件時,編輯屬性等)Javascript:如何做鏈接列表的功能或類似?
示例流程:
任務1:打開FileBrowser(iframe的瀏覽控制),選擇時,執行任務2 任務2:從FileBrowser獲取值,打開iframe FileProperties。完成後,執行任務3 任務3:獲得FileProperties ID,在頁面控制
每個任務必須等待從以前的任務回調ID添加到。我願意接受所有想法如何做到這一點!唯一的一步是生成服務器端,所以我需要避免硬編碼!以下是我迄今的嘗試!
所有想法,感激地收到。
FruitBat
/* action array */
var actions = new Array();
var data = {};
var op = function(fn, next, data) {
this.op = this;
this.fn = fn;
this.next = next;
this.data = data;
};
function one(myop) {
var op1 = myop;
var url = 'poptarget.aspx?cid=21&data=' + escape('[Id]=[2],[cid]=[3]');
var frame = $().popFrame('UniqueId', { caption: 'Page Item', url: url, width: 'auto', modal: true });
frame.bindEvent("cancelled saved", function(e, d) {
console.log('other');
callback();
});
frame.bindEvent("close", function(e, d) {
console.log('close');
op1.next.fn.call(op1.next);
});
};
function two(myop) {
console.log('woohoo');
};
actions.push(new op(one, two, null));
actions.push(new op(two, null, null));
var start = actions[0];
start.fn.call(start);
console.log(data);`