Search code examples
jquery-uiios5jquery-selectors

how to disable and enable select in jQuery mobile


I am doing web app for iOS using jQuery. I have a select in one page. According to the requirement I have to disable it.

      <select name="select-choice-a" id="selectCardType" data-native-menu="false">
           <option value="select">Select Card Type</option>
           <option value="A">American Express</option>
           <option value="M">Master Card</option>
           <option value="V">Visa</option>
      </select>

I have 2 scenario 'The user can come to the page directly or form another app by url scheme'

I have used

$('#selectCardType').selectmenu('disable');
or

'$('#selectCardType').attr('disabled', 'disabled'); `

But it is not working for me in either case.


Solution

  • thanks for your help. I got the solution.

    create one global variable var onceVisitedCardpage = false;

    if you have visited that page then make this variable as true

    then check the state of that variable before coming to that page

        if(onceVisitedCardpage)
            $('#selectCardType').selectmenu('disable');
        else
            $('#selectCardType').attr("disabled", "disabled");
    

    By this way I manage to handle both the senario.