0

I have a function, say

function runSomething()
{
   alert("hello");
}

I have window.onhashchange = runSomething;
And in my code, I call window.location.hash = "#processsection"

runSomething runs, however it runs before the page does to #processsection...how can I get it to only run AFTER I am on #processsection?

Bergi
  • 513,640
  • 108
  • 821
  • 1,164
antonpug
  • 11,964
  • 27
  • 76
  • 120
  • What do you mean with "AFTER"? After the UI scrolled to that anchor? – Bergi May 17 '12 at 23:16
  • yes! after JQuery Mobile has scrolled there! Basically I am not seeing whatever runSomething is doing until it has finished! – antonpug May 17 '12 at 23:16
  • In other words, it does some stuff and I am not seeing it because it doesnt go to that section until it has finished – antonpug May 17 '12 at 23:17
  • They do, but it's late in the night and you gave them only 12 minutes. [This is not](http://meta.stackexchange.com/q/128548/183280) a hotline :) – Bergi May 17 '12 at 23:28
  • is #processsection a page? i.e `
    `. Give us more code so we can see the bigger picture. Or if you can make a jsfiddle illustrating the problem.
    – codaniel May 17 '12 at 23:48

1 Answers1

0

In your scenario I would probably use an if condition to check if that div or body (whichever applies) is animating aka. scrolling. Here's an untested, rough idea.

function runSomething() {        
    if ($('body').is(':animated') {
        $('body').queue(function() {
            alert("hello");
        });
    } else {
        alert("hello");
    }
}
inhan
  • 7,038
  • 1
  • 20
  • 35