No puedo alcanzar entradas dinámicas con javascript

I want to change Cloudera Hue project code but I have some problems. Knockout data-bind is created some html codes with foreach , when I want to reach input in this html, my code does not work correct. My app.mako file code :

 <div data-bind="foreach: submissionVariables" style="margin-bottom: 20px">
  <div class="row-fluid">
    <span data-bind="text: name" class="span3"></span>
    <input type="text" data-bind="value: value,attr: { id: 'dtpicker' + name }" class="span9" />
    <button class="btn fileChooserBtn" data-bind="click: $root.showTimePicker">time</button>

<input type="text" value="2014/03/15 05:06" id="datetimepickerz"/>
<script src="/static/js/jquery.datetimepicker.js"></script>
<script type="text/javascript">
        .datetimepicker({value:'2015/04/15 05:03',step:10});
        .datetimepicker({value:'2015/04/15 05:03',step:10});
        .datetimepicker({value:'2015/04/15 05:03',step:10});


<input id="dtpickerfolder" class="span9" type="text" data-bind="value: value,attr: { id: 'dtpicker' + name }"></input>
<input id="dtpickereverything" class="span9" type="text" data-bind="value: value,attr: { id: 'dtpicker' + name }"></input>
<input id="datetimepickerz" type="text" value="2014/03/15 05:06"></input>

datetimepickerz input works correct but my dynamic inputs that ids starts with dtpicker are not working.

¿Alguien puede ayudarme?

preguntado el 28 de mayo de 14 a las 11:05

is name property observable?i will suggest you to use knockout custom binding for datepicker. -

yes observable. It like dtpicker+everything. I want to set date and time, I think knockout custom binding for datepicker is only get date property? -

ok then use parentheses for name field attr: { id: 'dtpicker' + name() }" -

I think my question is incorrect. I edit and write output. { id: 'dtpicker' + name} works correct. That's not my problem. -

1 Respuestas

I solve this with :

  self.runOrShowSubmissionModal = function runOrShowSubmissionModal() {
var script = self.currentScript();
if (! $.isEmptyObject(script.getParameters())) {
  $.each(script.getParameters(), function (key, value) {
    self.submissionVariables.push({'name': key, 'value': value});
    $("#dtpicker"+key).datetimepicker({value:"2015/04/15 05:03",step:10});
  $("#runScriptBtn").attr("data-loading-text", $("#runScriptBtn").text() + " ...");

    keyboard: true,
    show: true
} else {

I sent my jquery in knockout function.

contestado el 30 de mayo de 14 a las 12:05

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.