How to capture the “virtual keyboard show/hide” event in Android?

2020 Update This is now possible: On Android 11, you can do view.setWindowInsetsAnimationCallback(object : WindowInsetsAnimation.Callback { override fun onEnd(animation: WindowInsetsAnimation) { super.onEnd(animation) val showingKeyboard = view.rootWindowInsets.isVisible(WindowInsets.Type.ime()) // now use the boolean for something } }) You can also listen to the animation of showing/hiding the keyboard and do a corresponding transition. I recommend reading Android … Read more

Calling a function when ng-repeat has finished

var module = angular.module(‘testApp’, []) .directive(‘onFinishRender’, function ($timeout) { return { restrict: ‘A’, link: function (scope, element, attr) { if (scope.$last === true) { $timeout(function () { scope.$emit(attr.onFinishRender); }); } } } }); Notice that I didn’t use .ready() but rather wrapped it in a $timeout. $timeout makes sure it’s executed when the ng-repeated elements … Read more

Getting value of HTML Checkbox from onclick/onchange events

The short answer: Use the click event, which won’t fire until after the value has been updated, and fires when you want it to: <label><input type=”checkbox” onclick=’handleClick(this);’>Checkbox</label> function handleClick(cb) { display(“Clicked, new value = ” + cb.checked); } Live example | Source The longer answer: The change event handler isn’t called until the checked state … Read more

How to have click event ONLY fire on parent DIV, not children?

If the e.target is the same element as this, you’ve not clicked on a descendant. $(‘.foobar’).on(‘click’, function(e) { if (e.target !== this) return; alert( ‘clicked the foobar’ ); }); .foobar { padding: 20px; background: yellow; } span { background: blue; color: white; padding: 8px; } <script src=”https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js”></script> <div class=”foobar”> .foobar (alert) <span>child (no alert)</span> </div>

Launch Bootstrap Modal on Page Load

Just wrap the modal you want to call on page load inside a jQuery load event on the head section of your document and it should popup, like so: JS <script type=”text/javascript”> $(window).on(‘load’, function() { $(‘#myModal’).modal(‘show’); }); </script> HTML <div class=”modal hide fade” id=”myModal”> <div class=”modal-header”> <a class=”close” data-dismiss=”modal”>×</a> <h3>Modal header</h3> </div> <div class=”modal-body”> <p>One … Read more

How can I capture the right-click event in JavaScript? [duplicate]

Use the oncontextmenu event. Here’s an example: <div oncontextmenu=”javascript:alert(‘success!’);return false;”> Lorem Ipsum </div> And using event listeners (credit to rampion from a comment in 2011): el.addEventListener(‘contextmenu’, function(ev) { ev.preventDefault(); alert(‘success!’); return false; }, false); Don’t forget to return false, otherwise the standard context menu will still pop up. If you are going to use a … Read more

How to add a touch event to a UIView?

In iOS 3.2 and higher, you can use gesture recognizers. For example, this is how you would handle a tap event: //The setup code (in viewDidLoad in your view controller) UITapGestureRecognizer *singleFingerTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)]; [self.view addGestureRecognizer:singleFingerTap]; //The event handling method – (void)handleSingleTap:(UITapGestureRecognizer *)recognizer { CGPoint location = [recognizer locationInView:[recognizer.view superview]]; //Do stuff … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)