How to change dynamically appearance of a jQM text field
Hello,
I try to change the color of an input box once the user has changed something in it. I can see by alerts that the keypress event was catched but whatever element I try to give trigger('create') command after assigning a different data-theme the input text field is not refreshed with the correct color. Since I have tried various version combinations of jQuery and jQueryMobile without success I think that I do something conceptionally wrong.
In this forum I find several examples with lists, which work fine for me - but I haven't found the answer for the text field so maybe somebody here can point me on where to look at?
My html file:
- <script>
- $(document).on("pageinit", "#mypage", function () {
- $( "#mytextfield" ).keypress(function() {
- $('#mytextfield').attr( 'data-theme','b');
-
- $("#configpart").trigger("create");
- $('#allpagecontent').trigger("create");
- $('#mypage').trigger("pagecreate");
- });
- });
- </script>
- <div data-role="page" id="mypage">
- <div data-role="content" id="allpagecontent">
- <div data-role="collapsible" data-collapsed="false" id="configpart">
- <h3>Configuration</h3>
- <form action="#" method="get">
- <div data-role="fieldcontain">
- <input type="text" value="" data-mini="true" id="mytextfield" data-theme="a"/>
- </div>
- </form>
- </div>
- </div>
- </div>
Has somebody an idea?
With kind regards,
Steve