facebook

[SOLVED]How to dynamically hide/show a button?

  1. MobiOne Archive
  2.  > 
  3. Getting Help – General
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #319301 Reply

    WiZaxx
    Participant

    Hi again
    Is there a way to dynamically hide/show a given object, say… a button?

    I would like to set a var and by the value of it be able to either hide or show a button.

    #319335 Reply

    support-michael
    Keymaster

    @WiZaxx

    I ran into some problems recently trying to dynamically hide/show widgets. The issue is that MobiOne lays out widgets with relative positioning. Thus if you try to use JQuery show()/hide() or toggle() they all change the display property (display: none) which goofs up the layout. So after discussing with dev team I learned the approach is to set the css visibility property to ‘visible’ or ‘hidden’

    Here is a snippet from an example app that I worked on recently:

    function showStartBtn(aBool) {
      //$('#m1-stopwatch-startBtn').toggle(aBool); //goofs up layout
      
      if (aBool) {
        $('#m1-stopwatch-startBtn').css('visibility', 'visible');
        //$('#m1-stopwatch-startBtn').show();  //goofs up layout
      } else {
        $('#m1-stopwatch-startBtn').css('visibility', 'hidden');    
        //$('#m1-stopwatch-startBtn').hide(); //goofs up layout
      }
    }
Viewing 2 posts - 1 through 2 (of 2 total)
Reply To: [SOLVED]How to dynamically hide/show a button?

You must be logged in to post in the forum log in