C
codethief
Hello dear JavaScripters,
I'm currently trying to get a script (http://bitbucket.org/codethief/
pybsd/src/4890d9a4597a/static/js/jquery.inlineedit.js) working and
have run into a problem which you JavaScript gurus surely can solve in
no time unlike me (who certainly doesn't belong to this group, so
please bear with me.)
First of all, I'm doing an initial call, like so:
#
# window = WindowInteraction();
# window.load_url('http://...');
#
.... which should open up a small window / css layer containing the
website with the URL provided.
(BTW: Interestingly, if I use the exact URL for window.load_url()
under this script can be found, Google Chrome loops infinitely whereas
Firefox doesn't. The latter is the wrong behavior since jQuery
executes the JavaScript code in HTML data received over AJAX
(according to the docs). Does Firefox somehow prevent execution of
infinite loops or of JavaScript code received like this?)
Now, let's get to my actual problem in line 161 (http://bitbucket.org/
codethief/pybsd/src/4890d9a4597a/static/js/
jquery.inlineedit.js#cl-161):
The current version works so far which I rather achieved by guessing.
Because:
If I write
# 'success': this.load_html
or
# 'success': load_html
instead of the closure, it won't work at all ('this' is undefined in
load_html, then) because, apparently, the context is lost and
load_html is executed as stand-alone function. This is something I can
follow.
But, why doesn't the following run nicely?
# 'success': function(data) {
# this.load_html(data);
# }
.... results in: "this.load_html is not a function (line: 162)"
Shouldn't 'this' be available in the closure or is it some kind of
special variable? Why does a simply 'load_html(data)' (without 'this.'
in front of it) even work? Are all properties of an object accessible
like this (without 'this.' in front of them) from inside the prototype
function?
Thanks in advance for helping me understand this issue.
I'm currently trying to get a script (http://bitbucket.org/codethief/
pybsd/src/4890d9a4597a/static/js/jquery.inlineedit.js) working and
have run into a problem which you JavaScript gurus surely can solve in
no time unlike me (who certainly doesn't belong to this group, so
please bear with me.)
First of all, I'm doing an initial call, like so:
#
# window = WindowInteraction();
# window.load_url('http://...');
#
.... which should open up a small window / css layer containing the
website with the URL provided.
(BTW: Interestingly, if I use the exact URL for window.load_url()
under this script can be found, Google Chrome loops infinitely whereas
Firefox doesn't. The latter is the wrong behavior since jQuery
executes the JavaScript code in HTML data received over AJAX
(according to the docs). Does Firefox somehow prevent execution of
infinite loops or of JavaScript code received like this?)
Now, let's get to my actual problem in line 161 (http://bitbucket.org/
codethief/pybsd/src/4890d9a4597a/static/js/
jquery.inlineedit.js#cl-161):
The current version works so far which I rather achieved by guessing.
Because:
If I write
# 'success': this.load_html
or
# 'success': load_html
instead of the closure, it won't work at all ('this' is undefined in
load_html, then) because, apparently, the context is lost and
load_html is executed as stand-alone function. This is something I can
follow.
But, why doesn't the following run nicely?
# 'success': function(data) {
# this.load_html(data);
# }
.... results in: "this.load_html is not a function (line: 162)"
Shouldn't 'this' be available in the closure or is it some kind of
special variable? Why does a simply 'load_html(data)' (without 'this.'
in front of it) even work? Are all properties of an object accessible
like this (without 'this.' in front of them) from inside the prototype
function?
Thanks in advance for helping me understand this issue.