jQuery plugin to serialize a form and also restore/populate the form?

前端 未结 8 2084
花落未央
花落未央 2020-12-02 08:40

Is there a jQuery plugin out there that can serialize a form, and then later restore/populate the form given the serialized value? I know the form plugin can serialize as a

8条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-02 08:54

    A big thank you to Barnabas Kendall for his answer, very useful.

    However I found 1 error in it regarding restoring radio buttons, where instead of selecting the correct one it just copied the saved value to all buttons in group.

    Fortunately it's simple to fix. Just replace

    if(this.type == 'checkbox') {
    

    With

    if(this.type == 'checkbox' || this.type == 'radio') {
    

    and it will correctly update radio buttons

提交回复
热议问题