scope

Very strange Javascript scoping issue

北慕城南 提交于 2019-12-11 14:56:02
问题 The following variable my_cords is undefined when it gets to the google maps function, can anyone understand why and possible give me a work around? I have defined it right at the top and set it inside a callback function, which I have seen work on global variables before.. $(document).ready(function () { var my_cords; var map; function getCareHome() { geocoder = new google.maps.Geocoder(); //var address = document.getElementById("address").value; var address = "address here"; geocoder

Powershell global variable is not inherited by child scripts

孤街浪徒 提交于 2019-12-11 14:55:58
问题 I have a bunch of powershell scripts, broken down to keep things modular. However, all or most of these scripts rely on certain common variables, like the server they talk to, etc. I'm defining these variable in the global scope and accessing them in the scripts using $global:{Variable} syntax. This works fine in the script which serves as the entry point. However when the main (entry point) script executes a child script using the following syntax, I no longer can read the value of the same

Spring “session” scope of a bean

旧时模样 提交于 2019-12-11 14:53:59
问题 It seems to me that "session" scope is another means to keep objects in session as using setAttrubute / getAttribute Correct? You know, dont know why, it does not work for me. <bean id="sabreUser" class="util.MyUser" factory-method="getSomeUser" scope="session"> <const args...> What I see is that after the initialization and initial deploy the MyUser properties are correct. Then, in the first session I change MyUser property, the session is closed. The second session runs and it sees the last

How to check if the variable is set in the parent scope, (as opposed to being inherited from grandparents) in CMake?

倖福魔咒の 提交于 2019-12-11 14:53:35
问题 How to check if the variable is set in the parent scope, (as opposed to being inherited from grandparents) in CMake? In the ideal world, I would fancy having some sort of DEFINED_IN_PARENT_SCOPE predicate for the if construct, so in the following code function(child) if(DEFINED MYVAR) #First check if the variable is defined in any of the parents if(DEFINED_IN_PARENT_SCOPE MYVAR) message("Parent has defined MYVAR") else() message("Parent has inherited MYVAR from other function up in the call

AngularJS: Manipulate the $scope of an unknown $element

安稳与你 提交于 2019-12-11 14:48:49
问题 New to Angular. I'm creating a directive (attribute) for global use through the whole project. I'm using a local storage function and my intention is to have the element, on which the attribute is situated, change its value/text accordingly. Here is the HTML: <input type="email" name="username" placeholder="Email Address" ng-model='username' loadstorage="USERNAME" /> Here is the directive: .directive("loadstorage", function (localStorage) { return function ($scope, $element, attrs) { $scope.

Angular Form Resetting with Ajax Callbacks

谁都会走 提交于 2019-12-11 14:37:02
问题 I have a basic form with an Angular $save action run on submit: app.controller 'MyThingCtrl', ($scope, MyThing) -> this.addThing = -> new MyThing(this.thing).$save( (data) -> console.log 'New Thing Saved' $scope.things.push data this.thing = {} ,(err) -> console.log 'Error: ' + err ) The expectation is that the form for this.thing will be reset on success, but it isn't, as the this no longer refers to what it did before. 回答1: While the scope of this is changed inside the callback, the

How is package scope achieved?

血红的双手。 提交于 2019-12-11 14:24:37
问题 Meteor documentation (see section Namespacing) says: When you declare a top-level variable, you have a choice. You can make the variable File Scope or Package Scope. // File Scope. This variable will be visible only inside this // one file. Other files in this app or package won't see it. var alicePerson = {name: "alice"}; // Package Scope. This variable is visible to every file inside // of this package or app. The difference is that 'var' is // omitted. bobPerson = {name: "bob"}; This is

Shiny: observe change in global variable

你说的曾经没有我的故事 提交于 2019-12-11 14:18:45
问题 I am making a very simple game in Shiny. Basically every player plays in their own session, but they share 1 global variable to keep track of the scores of each player. I think I'm succeeding having sessions update the global 'scores' variable, but for some (probably dumb) reason I cannot get the global variable to act as a reactive value (i.e. automatically triggering updateActionButton). Minimal code below: working example: score <- c(100) ui <- fluidPage( titlePanel("Hello Shiny!"),

Python: Getting option from function?

不羁的心 提交于 2019-12-11 14:03:52
问题 I'm working with Tkinter in Python and am using OptionMenu and want to get the selection the user makes. ex1 = StringVar(root) ex1.set("Pick Option") box = OptionMenu(root, "one","two","three", command=self.choice) def choice(self,option): return choice It work when I just do: print choice But I though I could somehow return it and then store it in a variable. For example, at the start of the code I made: global foo foo = "" and then tried: def choice(self,option): foo = option return foo But

How to rewrite rails group_by class method as scope

情到浓时终转凉″ 提交于 2019-12-11 13:49:11
问题 I would like to rewrite my class method as a scope. class Team def self.grouped self.all.group_by { |e| e.type }.map { |k, v| { k => v.group_by { |e| e.sub_type } } } end end How would I write as a scope? class Team # scope :grouped ?? end 回答1: You cannot write this as a scope. Scopes in Rails act on ActiveRecord::Relation objects and are supposed to generate SQL queries that run against the database. But the group_by method is called on the array after the data was received from the database