kossnocorp/jquery.turbolinks — pull request #23 by zamith (2013-02-22 16:18:23+00:00)
Title: Adding run once callback

I came across this problem when trying to trigger callbacks on the context of a single page, i. e., in one page I wanted to run some JS that should not be ran on another page.

Since the stuff on the `

` will only be evaled once, I added this code to the body, which means it will be ran every time and for non-idempotent functions this is a problem.

I solved by having a special function called `run_once`, that is not added to the callbacks, and runs only on the context of the page.

If this makes any sense I'll be glad to add tests to it. If there's a better way of doing it, even better.