2010-06-04 19 views
1

我有以下代碼:jQuery的包裹迫使多個文檔準備回調

function CreateRoundbox(selector, scope) { 
    $(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>'); 
    $('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>'); 
} 

每當我用這個功能和「包裝」的方法被調用時造成的$(document)。就緒()方法在頁面上再次點燃。下面是對函數的調用(它生活在一個文檔就緒區塊中):

CreateRoundbox(".roundbox", "roundbox-wrapper");  

有沒有人遇到過這個?我使用換行錯了嗎?

UPDATE

固定的使用習慣,我不小心在範圍文本增加了一個點

+0

我很困惑,爲什麼都「逃脫 – Zuul 2010-06-04 01:47:09

+0

@ Zuul - ?哈哈...他就像這樣我猜...但這不是問題..是嗎?..) – Reigel 2010-06-04 01:51:21

+0

@Reigel,哈哈... nopes,但我只是看着它,無法把握我的頭; ) – Zuul 2010-06-04 01:56:07

回答

0
function CreateRoundbox(selector, scope) { 
          //   v----> this will result to class=".roundbox-wrapper", which is, I guess, not the thing you want in there.. :) 
    $(selector).wrap('<div class=\"' + scope + ' dialog\"><div class=\"bd\"><div class=\"c\"><div class=\"s\"></div></div></div></div>'); 
    $('div.' + scope).prepend('<div class=\"hd\"><div class=\"c\"></div></div>').append('<div class=\"ft\"><div class=\"c\"></div></div>'); 
    // ^^
    //  | |--- look at scope.... then, look here at the second argument, CreateRoundbox(".roundbox", ".roundbox-wrapper"); 
    //  |--- look at the dot.... :) CreateRoundbox(".roundbox", ".roundbox-wrapper"); 

} 
+0

我明白你在說什麼......我會更新上面的例子......我只是輸入了用法,並把它搞砸了;) – 2010-06-04 02:17:54

+0

哈哈帶着倒票......我希望至少有理由被解釋... ...爲進一步增強答案..;) – Reigel 2010-06-04 02:37:07

+0

是的,因爲它對實際答案沒有影響(我留下了一個解釋的評論,更不用說更新問題了)。如果這是問題的答案,它會得到讚揚。合理? – 2010-06-04 02:47:59