diff options
| author | hallgren <hallgren@chalmers.se> | 2010-12-01 16:20:28 +0000 |
|---|---|---|
| committer | hallgren <hallgren@chalmers.se> | 2010-12-01 16:20:28 +0000 |
| commit | a2b9a684c04a1b3225fff80c1572a39d46ffa87d (patch) | |
| tree | 419985fc48c9e33b9834b47a92e6cf71c4e4c7a0 /src/runtime/javascript | |
| parent | 9b6f775b760883b49fd9c56580f22dc5933a7d2a (diff) | |
support.js: add function bind (JS OOP trick)
Diffstat (limited to 'src/runtime/javascript')
| -rw-r--r-- | src/runtime/javascript/minibar/support.js | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/runtime/javascript/minibar/support.js b/src/runtime/javascript/minibar/support.js index 9633cfb28..01c585414 100644 --- a/src/runtime/javascript/minibar/support.js +++ b/src/runtime/javascript/minibar/support.js @@ -4,6 +4,14 @@ function element(id) { return document.getElementById(id); } +/* --- JavaScript tricks ---------------------------------------------------- */ + +// To be able to object methods that refer to "this" as callbacks +// See section 3.3 of https://github.com/spencertipping/js-in-ten-minutes/raw/master/js-in-ten-minutes.pdf +function bind(f, this_value) { + return function () {return f.apply (this_value, arguments)}; +}; + /* --- JSONP ---------------------------------------------------------------- */ // Inspired by the function jsonp from |
