Linked Questions
19 questions linked to/from Javascript Closures and 'this'
0
votes
1
answer
3k
views
Javascript, calling function within promise [duplicate]
Explanation of code
I have a function called placeDecode which takes an HTML input element. Within the function I have a promise which converts input value into a formatted address.
I called ...
0
votes
3
answers
1k
views
`this` in callback functions [duplicate]
I used to use
MyClass.prototype.myMethod1 = function(value) {
this._current = this.getValue("key", function(value2){
return value2;
});
};
How do I access the value of this within the ...
0
votes
1
answer
90
views
Using 'this' in a JavaScript Closure [duplicate]
I am building an app in JavaScript. I am trying to get my head around how to use this in a JavaScript closure. Currently, I have the following code:
var ExternalResource = require('ExternalResource');...
-1
votes
1
answer
44
views
Why is passing $(this) as a parameter not working [duplicate]
How come the following line:
pop = setInterval(function () { doSlide($(this)) }, settings.timeoutSet);
not sending the proper reference as the parameter.
I would like to set up the same ...
Si8's user avatar
- 9,255
0
votes
0
answers
47
views
"THIS" keyword conflict, when event function is nested inside the object [duplicate]
I have an idea to create an object Shout, which should take keyboard messages onkeypress event from the input element. When the user presses a key, there should appear alert box with shout exclamation....
1921
votes
16
answers
651k
views
How to access the correct `this` inside a callback
I have a constructor function which registers an event handler:
function MyConstructor(data, transport) {
this.data = data;
transport.on('data', function () {
alert(this.data);
...
20
votes
1
answer
24k
views
What are Closures and Callbacks?
What are closures and callbacks in JavaScript? I've yet to find a good explanation of either.
user avatar
user154759
4
votes
1
answer
5k
views
How to access an instance variable within a Promise callback?
Let's say I have a basic dumb javascript class :
var FunctionX = function(configs) {
this.funcConfigs = configs;
}
FunctionX.prototype.getData = function() {
return $.get('/url');
}
FunctionX....
3
votes
3
answers
4k
views
"this" keyword inside closure
I've seen a bunch of examples but can't seem to get some sample code to work.
Take the following code:
var test = (function(){
var t = "test";
return {
alertT: function(){
...
1
vote
1
answer
2k
views
Accessing a controller from inside a callback function in AngularJS
I have the following AngularJS controller:
controllers.controller('QueuesCtrl', ['$scope', 'QueueRes',function($scope,QueueRes) {
$scope.queues = QueueRes.query();
this.queue={};
this....
0
votes
1
answer
2k
views
Knockout data-bind scope variable "this"
I have a HTML element bound to one of observables in my view model that is build with John Resig's simple javascript inheritance.
<div data-bind="with: selectedItem()">
...
<div ...
1
vote
2
answers
376
views
AngularJS scope variable can't be set inside of a timeout [duplicate]
I have a jsfiddle for this issue.
https://jsfiddle.net/uvtw5kp1/4/
$scope.Dropdown = {
open: false,
searchValue: "",
timer: null,
hideIt: function() {
this.timer = $timeout(function() ...
3
votes
4
answers
105
views
exploring keyword "this" in javascript
I have following code block in javascript:
const obj = {
name: "sri1",
func1: function() {
const name = "sri2"
function a() {
console.log(this.name)
}
a();
...
0
votes
1
answer
197
views
Phonegap - deviceready not being fired
This code shows (i.e. alerts) "alert1" but not "alert2". I'm using a Samsung Galaxy Tab 3 7.0 as target device. The following code is in index.js.
EDIT: "alert3" is neither shown - for those who get ...
0
votes
2
answers
63
views
Polymer web app element null pointer exception
I am user iron-list with iron-ajax but after ajax response when pushing element to iron-list giving null exception = "Cannot read property '_list' of undefined"
<script>
Polymer({
...