Search code examples
javascriptjqueryextjssencha-touchsencha-touch-2

Sencha Touch 2: How to get HTML as well as input values from a panel


I was wondering how to get the HTML of a panel AS WELL AS the input values from a panel? I can get the HTML like:

myPanel.getInnerHtmlElement().dom.innerHTML

But that only return me the HTML. For example if I have some HTML like below in Panel:

<input type="text" name="firstname">

And then enter a name in the text box, it should come back something like:

<input type="text" name="firstname" value="John">

instead I am getting back:

<input type="text" name="firstname">

Does anyone know how to get the HTML back with the input values as well? Thanks.


Solution

  • Modified the value attribute on the DOM whenever the value was changed:

    $("input[type='text']").change(function () {
      $(this).attr('value', $(this).val());
    });
    

    And then got the HTML when needed via:

    myPanel.getInnerHtmlElement().dom.innerHTML