jQuery jPicker reset completely

前端 未结 3 476
情书的邮戳
情书的邮戳 2021-01-22 03:07

If anyone experienced with jPicker, I would really like some help on this. I have a jPicker input box in a form, and when I post the form with Ajax, I try to reset the form back

相关标签:
3条回答
  • 2021-01-22 03:24

    You can try to unbind the jPicker from the element and then rebind it after you want to reset it, should make it back to default settings.

    0 讨论(0)
  • 2021-01-22 03:27

    jPicker maintains the information for its control in the $.jPicker.List[] array. To remove the jPicker association with the control you will need to destroy its corresponding entry in the $.jPicker.List[] array.

    Loop through the list of items in the array to find the one that references the control with

    $.jPicker.List[index].id
    

    When you find your control in the array, destroy it with

    $.jPicker.List[index].destroy()
    

    After destroying the array element, you will need to remove the SPAN jPicker html object associated with the control. If there is only one you can

    $('span.jPicker').remove()
    

    otherwise you will need to discover the specific html element

    $(rowParent).find('span.jPicker').remove();
    

    Optionally: if you are using class reference vs. id reference, use the .data() function to tag your control and use the following statement to retrieve the unique value

    $( $.jPicker.List[index] ).data()
    
    0 讨论(0)
  • 2021-01-22 03:39

    As explained above you could try something like this :

    var id =$.jPicker.List[i].id; //getting the id of the element you've binded jpicker with
    $.jPicker.List[i].destroy(); //destroying the instance in the jPicker List
    $("#"+id).parent().find('span.jPicker').remove(); // destroying the span containing the graphical jPicker
    $("#"+id).jPicker(); // And finally reinstancing the jPicker instance on your element
    

    It should make blink your picker (removing then recreating).

    0 讨论(0)
提交回复
热议问题