How to programmatically set DurationBox value in jQuery Mobile DateBox2?

天涯浪子 提交于 2019-12-12 03:06:10

问题


I am using the DateBox2 PlugIn for my jQuery Mobile webpage.

I get a duration in seconds from a JSON Webservice which can be as long as multiple days (e.g. 86400s).

I want to post this in to my text input using the standard DateBox2 duration display like "1 Day, 00:00:00", but all I get is the plain seconds value.

I tried some combinations of .val(), .datebox("setTheDate", 86400), .datebox(callFormat, ...) but none of them seem to work.

Here is my input field:

<input class='period' type='text' readonly='readonly' data-role='datebox' data-options='{"mode": "durationbox", "showInitialValue": true, "useFocus": true}' />

Thanks in advance!


回答1:


Kindly use this:

$('element').trigger('datebox', {'method':'dooffset', 'type':'s', 'amount':86400}).trigger('datebox', {'method':'doset'});



来源:https://stackoverflow.com/questions/18960632/how-to-programmatically-set-durationbox-value-in-jquery-mobile-datebox2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!