2016-08-17 35 views
1

每當我嘗試初始化控制組時,它都會更改順序,以便文本輸入結束。jQuery-ui控制組textinput初始化時的訂單更改

預初始化: enter image description here

後初始化: enter image description here

HTML:

<fieldset> 
    <div class="controlgroup"> 
     <label for="instrID" class="ui-controlgroup-label">ID:</label> 
     <input type="text" name="instrID" id="instrID"> 
     <label for="instrAddr" class="ui-controlgroup-label">Address:</label> 
     <input type="text" name="instrAddr" id="instrAddr"> 
     <label for="dropDownFormat" class="ui-controlgroup-label">Format:</label> 
     <select id= "dropDownFormat"><option selected='DEFAULT'>DEFAULT</option><option>OPT_2</option><option>OPT_3</option></select> 
     <label for="radio-write" class="ui-controlgroup-label">Type:</label> 
     <label for="radio-write">Write</label> 
     <input type="radio" name="radio-wr" id="radio-write"> 
     <label for="radio-read">Read</label> 
     <input type="radio" name="radio-wr" id="radio-read"> 
     <button id="addCmd">Add Command</button> 
    </div> 

JS:

$(document).ready(function(){ 
    $(".controlgroup").controlgroup(); 
}); 

回答

2

API文檔顯示有'項目'屬性。在這個屬性中,你聲明瞭什麼類型將被轉換成控件組啓動時的小部件。

示例:控件組啓動時,input [type ='checkbox']將轉換爲新的「checkboxradio」小部件。

我並不積極,因爲我正在嘗試做與你一樣的事情,但我相信你需要將元素輸入[type ='text']添加到將要合併的項目進入這個對照組。踢球者是,你還需要聲明一個widget類型來將文本輸入轉換爲也。

如果沒有聲明元素類型input [type ='text'],JQuery-UI會解析默認支持的所有類型(支持的列表可以在這裏找到http://api.jqueryui.com/controlgroup/#option-items),然後在它之後留下的任何類型完成解析只是附加到結尾。

這就是爲什麼輸入[type ='text']顯示在行尾。

繼續 - 所以我測試了將輸入[type ='text']添加到外部的各種控件類型,並使控件組看起來有點時髦。但是,如果你絕對需要,你可以將其添加到'controlGroupLabel',然後添加一些自定義CSS項目到您的輸入框。

所以你對照組的jQuery應該是這樣的:

$('.controlGroup').controlGroup({ 
    items: { 
    "button": "input[type=button], input[type=submit], input[type=reset], button, a", 
    "controlgroupLabel": ".ui-controlgroup-label, input[type='text']", 
    "checkboxradio": "input[type='checkbox'], input[type='radio']", 
    "selectmenu": "select", 
    "spinner": ".ui-spinner-input" 
    } 
}); 

願望JQuery用戶界面團隊將添加文本輸入和其他投入對照組的能力。

+0

您也可以嘗試將輸入的文本類型添加爲自動填充小部件。那麼至少它將保持文本樣式輸入而不是標籤樣式。 – Alex

0

控制檯中的任何JS錯誤?你沒有空房間了嗎?嘗試刪除所有這些元素的一半,看看你是否得到相同的行爲。

+0

我試圖消除一切,但標籤和文本輸入,但我仍然得到同樣的結果。沒有錯誤。 – user3232337

-1

這是一個老話題,但我沒有在其他地方找到答案或具體問題。

經過幾次測試,我找到了以下解決方案。

請勿修改.controlgroup()。只需在您的label s和input type="text"上添加ui-controlgroup-item類。

問候, 安東尼