javascript - Using TimePicker or Datepicker in Durandal template project -
i new durandal. have tried of adding time picker project follows. schedule.js code:
define([], function (require) { var script = require('jquery.pttimeselect'); var app = require('durandal/app'); var vm = { viewattached: viewattached, }; return vm; function viewattached(view) { $(view).find('#sample1').pttimeselect(); //$('#sample1').pttimeselect(); console.log("activated schedule module"); return true; } });
here jquery.pttimeselect time picker js file. need add jquery.pttimeselect.js here or else.
schedule.html :
<section> <p> <label>start</label><br /> <input id="sample1" class="ui-widget-content" name="s1time2" value="" /> </p> </section>
problem facing getting basic time picker @ bottom of page. not getting add js , css files project. please new this.
i using timepicker following link http://pttimeselect.sourceforge.net/example/index.html
to , running solid timepicker control , durandal can follow these steps.
add these scripts page in same order below order. add them standard tags before load require/durandal.
- jquery http://jquery.com/
- jqueryui http://jqueryui.com/
- this timepicker control (built on jquery ui) http://fgelinas.com/code/timepicker/
- the jqueryui knockout bindings steve saunderson heiserman mentioned. https://github.com/stevesanderson/knockout/wiki/bindings---jqueryui-widgets
here how might reference scripts above, these scripts tags should go main layout page, index.html or whichever page hosting durandal application:
<head> <script src="/scripts/jquery-1.9.1.js"></script> <script src="/scripts/jquery-ui-1.10.0.js"></script> <script src="/scripts/jquery.ui.timepicker.js"></script> <script src="/scripts/knockout-jquery-ui-widget.js"></script> <script type="text/javascript" src="/app/durandal/amd/require.js" data-main="/app/main"></script> </head>
then can create timepicker in durandal view this:
<input type="text" placeholder="choose time" data-bind="jqueryui: { widget: 'timepicker', options: { showperiod: true }}">
Comments
Post a Comment