0

Whenever I click on a bootstrap button in the app, its gets stuck in a active or hover state, unless I click somewhere on the screen. So I'm thinking thats a easy solution

1) detect when someone clicks a bootstrap button

$(document).on('touchstart', '.btn', function(){ 
    console.log("button touch"); 
});

2) How can I somehow click somewhere on the screen so button is unstuck? (touchend event is occuring on bootstrap buttons)

$(document).on('touchend', '.btn', function(){ 
    console.log("button touch end");
    // ?????????????
});

My bootstrap buttons get stuck on phonegap app and I've tried all these answers

1) doesn't fix problem at all Bootstrap buttons get "stuck" down on mobile devices

2) I don't wanna change background bootstrap 3 button hover/focus state

Community
  • 1
  • 1
Web Development
  • 421
  • 1
  • 3
  • 15
  • You are on the right path. Basically, if you want to avoid this behavior you have to not use `:hover` pseudo-classes and instead write your own handlers for `mouseenter mouseleave touchstart touchend` (etc) that toggle a class or attribute on the element in question. Note that `touchend` might not occur on the targeted element and there may be multiple touch points at any given time. For more information, I'd recommend [this answer](http://stackoverflow.com/a/22444532/1028949) to a similar question. – jeffjenx Dec 09 '15 at 16:19
  • oh ok so do you recommend digging into boostrap js and customizing these functions? – Web Development Dec 09 '15 at 17:07
  • btw touch end event is occuring on bootstrap buttons – Web Development Dec 09 '15 at 17:45

1 Answers1

0

You should probably find out the underlaying issue. But to answer your question you can use tigger or click. Taking the example from the links:

$( "#target" ).click(function() {
    alert( "Handler for .click() called." );
});
$( "#other" ).click(function() {
    $( "#target" ).click();
});
Filipe Teixeira
  • 3,565
  • 1
  • 25
  • 45
  • .click() doesn't work. I have a another button hidden in the navbar, I tried clicking that button on the ontouchend function programatically but it doesn't have the same affect as physically touching the button – Web Development Dec 09 '15 at 17:04