scope

How to get data from jquery callback to parent function

Hi, I'm using the jquery ui drag/drop code. Upon a drop a getJSON request gets executed to check the new data and update the database. This works fine, until my backend return an error, because I can't cancel the drop from within the anonymous function. If there's an error the backend returns json that looks like this: {"result":0} ...

Scoping issues in javascript classes

The classical programmer in me is in love with the public/private paradigm of OO and I am finding it very hard to give up. This has caused me to run into an issue I was hoping you can help me with. I have a singleton object called map. There can be only one. This map contains objects called Star (it's a game). A Star looks like this: ...

What is the difference between Dim, Global, Public, and Private as Modular Field Access Modifiers?

In VB6/VBA, you can declare module-level variables outside of a specific Sub or Function method. I've used Private and Public before inside modules and understand them like so: Public - visible to all code inside the module and all code outside the module, essentially making it global. Private - visible only to code inside the module....

Data Binding Scopes - In Need of clarification.

I've been doing some work in WPF, and I for the most part have my bindings working, but I need a scope clarification here. I've run into some seemingly simple operations that require silly binding workarounds and I believe a lot of it has to do with scope. Example #1 - Out of visual tree, binding to parent. <ComboBox x:Name="Combo1" It...

Change SharePoint scope at runtime.

I have a requirement where based on a users SharePoint group, there search should be a specific scope. My question is, is it even possible to change the SharePoint search box to use search a particular scope at runtime? ...

Google maps - pass information into an event Listener

I think this is a scope problem. Since the event is triggered after I have added all the listeners num_markers has always been overridden by the next cycle in the loop. Is there some way I can pass variables to the event function? I tried this approach but it didn't for me. http://stackoverflow.com/questions/1841247/google-maps-event-l...

Javascript and jQuery getting the right this

I have some sample code that looks like this: var myDrawingArea = new DrawingArea(document.getElementById("drawing_canvas")); function DrawingArea(aCanvas) { this.brushSize = 2; this.buildToolbar = (function () { $("#brush-size") .slider({ value: this.brushSize, // this is DrawingArea insta...

Variable scope in VBScript functions

I have a question about variable scope in VBScript. I know there's the following keywords (from autoitscript.com): Dim = Local scope if the variable name doesn't already exist globally (in which case it reuses the global variable!) Global = Forces creation of the variable in the Global scope Local = Forces creation of the variable in ...

Variable scope in PHP

I have an issue with php. The following code generates the error "PHP Warning: mysqli_close() expects parameter 1 to be mysqli, null given[...]" on the line containing the mysqli_query <html> <head> <?php $table = "prjsuggestions"; /$mysqli = NULL; if(!empty($_POST['posttext'])){ $pnameempty = empty($_POST['postnam...

Instantiating two objects inside a method for use as 'return values'

I've got the following class: public class Matriz { ... static public void create(Matriz a, Matriz b) { ... a=new Matriz(someValue,anotherValue); b=new Matriz(someValue,anotherValue); ... } } And in my main method: public static void main(String[] args) { Matriz a=null,b=null; Matriz.create(a,b); ...

Can I return data from an anonymous callback function in jQuery?

I'm sure this is simple, but I'm tripping up over a scope issue in Javascript. I'm doing the following: $.get(url, function (data){console.log(data);}); This part works fine - I see the string that I want appear in the console. But what I actually want is to take that data variable and place it in a string. Something like this (doesn'...

In cmd.exe, how can you get one variable to escape the setlocal command?

I frequently find myself using setlocal within cmd.exe to avoid polluting the environment variable space with temporary variables (and to ensure both command extensions and delayed expansion are active). However, I'm at a loss on how to do this if I actually want one of those variables to be made available. Consider the following code ...

ASP.NET C# scope issue

OK, so I'm tyring to work with some simple stuff in ASP.NET and C# to get the hang of the super super basics, and I'm having trouble finding out how I can get this scope issue to work. At least, I think it's a scope issue! :) So, here is my Default.aspx presentation markup: <%@ Page Language="C#" Inherits="project1.Tree" %> <!DOCTYPE ...

What is the scope of a java variable in a block?

I know in c++ variables have block scope, for example, the following code works in C++ void foo(){ int a = 0; for(int i = 0; i < 10; ++i){ int a = 1; //re-define a here. } } but this snippet doesnt work in java, it reports "duplicate local variable a", does it mean java variables dont have BLOCK scope? ...

Scope problem in JS: Uncaught TypeError: Object #<an Object> has no method 'createDocumentFragment'

I'm trying to make instrument to simplify work with complex grids of jqGrid, a function that could read schemes of grids, but looks like i lack JS skills for that ) function renderGridSystemRecursively(scheme, container){ // CHILDREN if ('children' in scheme && scheme.children.length > 0) { scheme.prm.gridPrm.subGrid = true...

Using "Static" Keyword to Limit Access in C++ Member Functions

I understand that one benefit of having static member functions is not having to initialize a class to use them. It seems to me that another advantage of them might be not having direct access to the class's not-static stuff. For example a common practice is if you know that a function will have arguments that are not to be changed, to...

Dynamic/Static scope with Deep/Shallow binding (exercises)

I'm studying dynamic/static scope with deep/shallow binding and running code manually to see how these different scopes/bindings actually work. I read the theory and googled some example exercises and the ones I found are very simple (like this one which was very helpful with dynamic scoping) But I'm having trouble understanding how stat...

Is the following JavaScript construct called a Closure?

(function() { //do stuff })(); EDIT: I originally thought this construct was called a closure - not that the effect that it caused results (potentially) in a closure - if variables are captured. This is in no way to do with the behaviour of closures themselves - this I understand fully and was not what was being asked. ...

How to use Rails 3 scope to filter on habtm join table where the associated records don't exist?

I have an Author model which habtm :feeds. Using Rails 3 want to setup a scope that finds all authors that have no associated feeds. class Author < ActiveRecord::Base has_and_belongs_to_many :feeds scope :without_feed, joins(:feeds).where("authors_feeds.feed_id is null") end ...doesn't seem to work. It feels like a simple t...

Faster to reuse a variable defined in a common scope or redefine it in each inner scope?

C++ specifically, if it matters, but I imagine the answer lies in assembly code somehow. If we have multiple blocks in a common scope (say, a function) which each use a variable of the same type, is it faster to define the variable in the common scope and reinitialise it in each block, or redefine and initialise it in each of the blocks...