0

I'm trying to load javascript using jquery .live() and binding it to pageshow. However, this doesn't work with IE (figures!), is there a compatible event I can bind to for IE?

$(".root").live('pageshow', function(event, ui) {
    alert("HERE");
});
netwire
  • 7,108
  • 12
  • 52
  • 86

3 Answers3

1

See this answer by 'thorie' to a similar issue. His idea of checking a hidden field (dirty bit) works in IE and Chrome. Then you add in a seperate line to work in Firefox; bind to pageshow and check event.originalEvent.persisted.

I may be two years too late to help you, but hopefully someone else may find this of use (or I will be corrected for my idiocy perhaps?!).

Community
  • 1
  • 1
Magnus Smith
  • 5,895
  • 7
  • 43
  • 64
1
$('#mypage').live('pageshow', function (event, ui) {

it should work

Try to give id instead of class name of element u are referring for pageshow

Mohan Ram
  • 8,345
  • 25
  • 81
  • 130
0

The pageshow event is not recognized by IE, it wont fire. JQuery already has the solution, the ready handler

$(document).ready(function(){ //your code })

or the shorter version, which is the same thing

$(function(){ //your code })

If you really want to use pageshow in a cross-browser way, trigger it from within ready

$(function(){
     $(document).trigger("pageshow")
})

and handle the pageshow event using your handler

Adil
  • 2,092
  • 3
  • 25
  • 35
  • 1
    The 'ready' event is not the same as 'pageshow' - see https://developer.mozilla.org/en-US/docs/Using_Firefox_1.5_caching – Magnus Smith Nov 05 '12 at 17:39