I want to implement my piece of code on click of a browser back button and a back link on right click of a mouse.
Kindly help me
window.onbeforeunload = function() { //dosomething();
};
Related
This is the link of the the example I am talking about.
Go to the link
https://angular-ui.github.io/bootstrap/
then check the datepicker example in plunker.
If we look in the code, I don't see any magic code there to do the closing part.
All I see is
$scope.open = function($event) {
$scope.status.opened = true;
};
which only opens the calendar.
My questions is how does it close on a click event that is outside of the calendar. This is a pretty good feature that I want to have on my other directives too.
---------------------Temp Solution----------------
Since no1 have provided an answer yet. For any1 who wants to know how to do this. I have a temp solution for you guys.
1. Add ng-click on the outter most tag.
2. Add ng-mouseleave and ng-mouseenter event on your custom tag.
Here is the flow:
When user mouse out/in of your custom tag. You set a flag to true/false.
Then when user clicks, close the div when mouse is outside the custom tag (You will use the flag to check ).
I found it myself.
It is because of the following code.
var documentClickBind = function(event) {
if (scope.isOpen && event.target !== element[0]) {
scope.$apply(function() {
scope.isOpen = false;
});
}
};
I have the following problem:
In my application every link has a tooltip (from bootstrap-ui). If the link is clicked, a alert dialog appears and the tooltip disappears. But in firefox the tooltip is still shown!
Here is a plunker:
plunkr
And thats how I want to use it with tooltip:
<a tooltip="do something" tooltip-popup-delay="300" tooltip-placement="bottom" ng-click="doSomething()">do Something</a>
the function:
$scope.doSomething = function()
{
alert("do Something");
}
After the alert window is confirmed, the tooltip is still shown in firefox.
Can someone help me, how to hide this tooltip in firefox? This is really stupid!
Thank you!
You can manually hide your tooltips by using jQuery like this:
jQuery('.tooltip').hide();
This will hide all instances of the tooltip. In your case, you could call this right after your alert like so:
$scope.doSomething = function()
{
alert("do Something");
jQuery('.tooltip').hide();
}
Make sure you add the jQuery library if you go with this approach.
I have an angular application where I am showing some menu bar upon clicking on an icon. I am using a scope variable and using ng-show to show/hide the same. It works fine, but there is a new requirement which states that if someone clicks on any other part of the application the menu should close. Now the problem is that when I am using an ng-click in the body it is triggering both the scope methods, i.e. for the icon click as well as the body click, since the icon is also within the body. What approach should I take for this? Do I need a different controller for the same?
on the click event you need to make sure the target is not the icon (consider also excluding the menu itself).
something like this:
$document.on('click', function (event) {
if (event.pageX == 0 && event.pageY == 0) return;
var target = event.target || event.srcElement;
if (!(elm.contains(target))) {
// close the menu
}
});
elm is your icon element
also, consider using a directive such as: https://github.com/IamAdamJowett/angular-click-outside
In the close listener added to the body, check that the event doesn't come from your the icon:
var closeListener = function(event) {
if (!iconElement.contains(event.target)) {
closeMenu();
}
};
i've been modifying my popup menu inside side menu for a while in ionic framework, and trying to close the side menu on click from the button i've created in the popup. Are there any possible way to do so ?
function ContentController($scope, $ionicSideMenuDelegate) {
$scope.toggleLeft = function() {
$ionicSideMenuDelegate.toggleLeft();
};
}
For close menu:
$ionicSideMenuDelegate.toggleLeft(false);
code from ionic:
Can you please tell me how to get click event of button? Actually button click event does not fire.
Here is plunker
http://plnkr.co/edit/cqmwJc5dpoDWvai4xeNX?p=preview
var loginCntrl=function($scope){
$scope.testClick =function(){
alert('sss');
}
}
You are making a simple mistake by not including ng-controller. Change it as follows. It will work.
<div ng-app="firstApp" ng-controller="loginCntrl">
<ui-view name="test"></ui-view>