Search code examples
jqueryjsrenderjsviews

How to change model by JQuery using JsRender technology?


I use jsViews in my project and faced with the problem: When I change the value of input using JQuery the DOM is not changing.

I use custom tag:{^{edit NOTE holderWidth='90'/}}, pm.mACQUAINTANCE.Items[2].row.NOTE in DOM is "1111" on aspx page {^{edit}} is tag <input id="472_ACQUAINTANCE_NOTE" class="valid" name="NOTE472">

after $("#472_ACQUAINTANCE_NOTE").val("2222"); $("#472_ACQUAINTANCE_NOTE").val() will "2222", pm.mACQUAINTANCE.Items[2].row.NOTE in DOM is still "1111"

:( Help please


Solution

  • If you want to change the value in the input using jQuery, and you want that value to trigger an update to the model, you will need to write

    $("#472_ACQUAINTANCE_NOTE").val("2222").change();
    

    or

    $("#472_ACQUAINTANCE_NOTE").val("2222");
    $("#472_ACQUAINTANCE_NOTE").change();
    

    to trigger a DOM element change event - which will then trigger the data binding.

    (You can also use either change() or blur())