2016-09-27 41 views
0

我想使用時間選擇器小部件作爲jQuery插件dForm的一部分。dForm插件添加時間選擇器小部件

具體這個timepicker小部件, https://github.com/jonthornton/jquery-timepicker

我讀了D-型文檔,但不能找到一種方法,使用自定義窗口小部件,如timepicker一個內D-型。我對JavaScript世界還很陌生,所以我可能忽略了一些明顯的東西,我爲此道歉。

有人願意告訴我該怎麼做嗎?這裏是我的jsfiddle到目前爲止

http://jsfiddle.net/nax97af6/

這是不是真的這樣做,除了貼標籤上說請選擇時間任何東西。

欣賞任何指針。

我的HTML

<form id="myform"></form> 

我的JavaScript

$("#myform").dform({ 
    "action": "index.html", 
    "method": "get", 
    "html": [{ 
     "type": "p", 
     "html": "You must login" 
    }, { 
     "name": "username", 
     "id": "txt-username", 
     "caption": "Username", 
     "type": "text", 
     "placeholder": "E.g. [email protected]" 
    }, { 
     "name": "timepicker", 
     "id": "timepicker", 
     "caption": "Pick Time", 
     "type": "timepicker", 
    }, { 
     "name": "password", 
     "caption": "Password", 
     "type": "password" 
    }, { 
     "name": "ruleenabled", 
     "type": "radiobuttons", 
     "id": "radiobuttonalign", 
     "caption": "Make rule available for use", 
     "options": { 
     "No": "No", 
     "Yes": { 
      "checked": "checked", 
      "caption": "Yes" 
     } 
     } 
    }, 

    ] 
}); 



$(document).ready(function() { 
    $('ui-dform-text').timepicker({}); 
}); 

我的CSS:

body { 
    font-family: sans-serif; 
    padding: 10px; 
} 

label, 
input { 
    display: block; 
    margin-top: 10px; 
} 

謝謝

回答

0

我想我解決我自己的問題:

這是我D-型碼

{ 
    "name" : "Time Picker", 
    "type" : "input", 
    "caption" : "Park Starting At", 
    "wickedpicker" : {} 
    } 

這是我添加腳本:

<script> 
    $.dform.subscribe("wickedpicker", function(options) { 
    this.timepicker(options); 
    }); 
</script> 

打開着聽到可以到這個代碼進行任何改進。

謝謝