JQuery Mobile Button Turn on / off and automatically change the TextArea format after changing

  • How to disable / enable the button? which is not in form, in navBar. I tried a few examples, all failed.

  • I am changing the text textarea $("textarea").val(x);The text is changing, the problem is that it does not get auto-resized, I see an ugly scroll bar on the side, if I manually resize it, it’s OK ... there is a way to force an update or something like that ?

thank

Update (TextArea):

If I click on a text area and then press any key -> it opens as it should, I try to simulate it .. but it fails, the binding works, but the trigger for keypress / keydown does not, I tried some codes from googling, this should work I think mayb for nomral jQuery 1.6 but not jQuery mobile. My tests on Chrome and iPhone 4

$('#textarea').bind('click', function() {
    var e = jQuery.Event("keypress", { keyCode: 64 });
    $(this).trigger( e );
});
+3
source share
2 answers

UPDATE:

Example link button:

Js

var clicked = false;

$('#myButton').click(function() {
    if(clicked === false) {
        $(this).addClass('ui-disabled');
        clicked = true;
        alert('Button is now disabled');
    } 
});

$('#enableButton').click(function() {
    $('#myButton').removeClass('ui-disabled');
    clicked = false; 
});

HTML

<div data-role="page" id="home">
    <div data-role="content">

        <a href="#" data-role="button" id="myButton">Click button</a>
        <a href="#" data-role="button" id="enableButton">Enable button</a>

    </div>
</div>

NOTE: - http://jquerymobile.com/demos/1.0rc2/docs/buttons/buttons-types.html

, , , , . buttonMarkup , (, , ) . ( ), ui-disabled JavaScript .

+2

, textarea keyup().

, :

/*Note: I'm using 'on' instead of 'bind', because that what I've actually tested 
with, but I'm pretty sure this will work with 'bind' as well*/
$('#textarea').on('click', function() {
    //First we'll add some text to #textarea
    $('#textarea').val('some dummy text to be added to the textarea');
    //Then we trigger keyup(), which causes the textarea to grow to fit the text
    $('#textarea').keyup();
});

, :

$('#textarea').on('click', function() {
    $(this).val('some dummy text to be added to the textarea').keyup();
});

.

+1

All Articles