I've got some problems with events in Angularjs. So I have an event in SomeCtrl implemented like this.
$scope.$on('event', function () {
// some logic
}
When I'm debugging in Chrome and Firefox, then debugger stops on breakpoints inside $on. But on IE, it doesn't. Someone knows, what can be, a solution to this?
EDIT:
I execute function like this where I want to fire event:
function doBroadcast(eventName, data) {
$rootScope.$broadcast(eventName, data);
}
Eventname is good, I checked it with debugger. I'm using IE11 and when I'm checking on IE9 with compability mode, then event is firing. But on IE10 and IE11 don't. My Angularjs ver. is 1.0.8.
Related
I have a handler that I use to detect when a user has focused the window, this works perfectly on Chrome but the event is not firing on IE11.
The event handler looks like: window.addEventListener('focus', this.doSomething);
Is there an IE11 equivalent of the above?
I have tried focusin but the behaviour is different and breaks my app.
Thanks
I tried and it worked on both Chrome and IE11:
window.addEventListener('focus', function () {
alert("focused")
})
Would you pls post your code?
I'm trying to detect hashchanged which works fine in every browser except chrome. For example, with this code:
if ("onhashchange" in window) {
alert("The browser supports the hashchange event!");
}
The statement is never executed in Chrome but works in Firefox. I've seen a jQuery hashchange plugin on GitHub but didn't have any luck with that either.
Any ideas?
my script reads something like this:
$(window).bind('popstate', function() {
//some code
//few more lines of code
});
This function works perfectly as intended in Chrome and Safari browsers. But Firefox for some reason ignores this function and does not work as intended.
Instead of using:
$(window).bind('popstate', function() {
//some code
//few more lines of code
});
You can use:
window.onpopstate = function() {
//some code
//few more lines of code
}
As firefox is using W3C defined rules for history API, so you have to use this for firefox and it works in chrome, safari and other browsers as well.
Note that just calling history.pushState() or history.replaceState()
won't trigger a popstate event. The popstate event is only triggered
by doing a browser action such as a click on the back button (or
calling history.back() in JavaScript).
Browsers tend to handle the popstate event differently on page load.
Chrome and Safari always emit a popstate event on page load, but
Firefox doesn't.
https://developer.mozilla.org/en-US/docs/Web/Reference/Events/popstate
Are you saying Chrome and Safari fire the event on page load or when the browser's back button is clicked? If the former, it's because Chrome/Safari are out of compliance with the HTML5 specs => the event should never be fired on page load. Up-vote https://code.google.com/p/chromium/issues/detail?id=63040 to get Google to fix this.
Please do Check that if you have coded window.load() more than once OR have called .onload() more than one time. This probably may work for IE but not for Chrome and fireFox.
I'm trying to bind some functions to an event.
The following code works perfectly fine in Chrome and FF but what's the corresponding code for IE?
$this.mouseenter(function(){
console.log("inside the mouse enter handler");
});
I tried this but it didn't work in IE:
$this.bind('mouseenter', function(){
console.log("inside the mouse enter handler");
});
I need it to work in at least IE 9.
console.log or at least console will give you an error on IE... hence, your javascript will not work... try using alert...
Unable to understand what is wrong # your end.
I tried this and its working fine for me.
console.log will return a js error, if your browser's console is not open. It will happen in any browser, not only with IE. Probably you tried FF and chrome with the browser console open and IE without opening the browser console. Try opening the browser console open in IE as well / by using alert() to test your funcitonality / by directly writing the functionality that you need.
Hope it helps!!!
I'm building a touchscreen kiosk using Chrome (7.0.536.2 dev) in kiosk
mode on a Windows 7 PC with multi-touch display.
I can see that the ontouchstart event is available (by inspecting the
window object in Webkit Web Inspector) but it never fires. If I write
the following code, the onclick event fires when I touch the screen
but the ontouchstart event doesn't.
window.onclick = function() { alert("click"); }
window.ontouchstart = function() { alert("touchstart"); }
In Firefox 4 the MozTouchDown event fires without any problems.
Are these events not yet available to JavaScript?
I experienced this when developing an iPad webapp and tried to test it in Chrome. It turned out, that Chrome recognizes those events, but does not fire them at the moment. This is a bit frustrating, since it breaks support detection in JavaScript.
There is a command-line switch to enable touch events, change your shortcut adding "chrome.exe --enable-touch". Unfortunately, if ('ontouchstart' in window) returns true then, event is never fired. Just tested this on a Windows7 touch-enabled tablet on canary channel. Disappointing... !
as of chrome 20, you can enable touch events from the "about://flags" internal experiments webpage
I did notice that this breaks fastClick, if you're using that - I was :)