jquery timepicker not working in phonegap android

青春壹個敷衍的年華 提交于 2020-01-06 14:56:16

问题


I am creating an app in which i want to app datepicker to select birthdate so for that i tried to use jquery-ui-timepicker-addon.js but the problem is when i tried to use it statically in the div then it shows the dateselector but when i try to create it dynamically it's not working can any one tell why its acting like this and where i am making mistake here is the code for creating dynamic datepicker:

    var creatText = $(document.createElement('input')).attr('type','text');
    creatText.attr('class','datetimepicker');
    creatText.attr('id','birthdate');
    creatText.attr('size','25');
    creatText.attr('placeholder','Birth Date');
    creatText.appendTo('#contentdemo');

here is the code for creating date selector statically and its working fine:

<div data-role="content" id="contentDemo">
<div data-role="collapsible-set" data-content-theme="c" style="margin-left: 8px;margin-right: 8px" id="dynamic_actionform">
</div>
  <input class='datetimepicker' placeholder="birth date" size='25'>
</div>

here is the example in github for the js files im usingenter link description here error in the logcat:

logcat09-05 06:37:41.943: D/CordovaLog(2822): Uncaught Error: no such method 'value' for slider widget instance 09-05 06:37:41.943:

E/Web Console(2822): Uncaught Error: no such method 'value' for slider widget instance at file:///android_asset/www/js/jquery-1.7.1.js:552

Thanks in advance.


回答1:


I believe you need to call .datetimepicker() on the new element after you've appended it to the DOM like so:

$('#contentdemo').append('<input type="text" id="birthdate" size="25" placeholder="Birth Date">');

// This should initialize the datepicker functionality
jQuery('#birthdate').datetimepicker();



回答2:


var creatText = $(document.createElement('input')).attr('type', 'text');
creatText.attr('class', 'datetimepicker');
creatText.attr('id', 'birthdate');
creatText.attr('size', '25');
creatText.attr('placeholder', 'Birth Date');
creatText.appendTo('#contentDemo');

$('.datetimepicker').datetimepicker()

You spelt contentDemo as contentdemo when appending.

Fiddle Example



来源:https://stackoverflow.com/questions/18531851/jquery-timepicker-not-working-in-phonegap-android

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