scope

Sass variable default scope

江枫思渺然 提交于 2019-12-29 04:16:12
问题 I have a problem with using variable defaults in Sass across scopes. My test example is: @mixin foo { $val: 'red' !default; .bar { color: $val; } } @include foo; .class1 { $val: 'green'; @include foo; .class11 { @include foo; } } $val: 'black'; .class2 { @include foo; } .class3 { $val: 'blue'; @include foo; } .class4 { @include foo; } It is compiles to: .bar { color: "red"; } .class1 .bar { color: "red"; } .class1 .class11 .bar { color: "red"; } .class2 .bar { color: "black"; } .class3 .bar {

How to use unscoped on associated relations in Rails3?

时光毁灭记忆、已成空白 提交于 2019-12-29 02:47:47
问题 I have a default scope on products due to information security constraints. class Product < ActiveRecord::Base has_many :photos default_scope where('visible = 1') end In my associated Photo model, however, I also have to find products that should not be visible. class Photo < ActiveRecord::Base belongs_to :product end my_photo.product In other cases, I can use unscoped in order to bypass the default_scope, e.g. in Product.unscoped.find_by_title('abc') . However: How to remove the scope when

making sure a function does not use a global variable [duplicate]

南笙酒味 提交于 2019-12-29 01:38:13
问题 This question already has answers here : R force local scope (11 answers) Closed 5 years ago . This maybe a bit converse to similar questions. I would like R to abort\warn if anywhere in the code, a function uses a variable in a parent environment. Is there some base option to achieve that? I would like a solution that is general for a session, not a particular check. Thank you. 回答1: There is a function findGlobals in the codetools package. Maybe this is helpful: library(codetools) x <-

Setting property value of parent viewcontroller class from child viewcontroller?

时光总嘲笑我的痴心妄想 提交于 2019-12-28 18:49:09
问题 Does anyone know how to update a property value from the subview (child) view controller? I have a int property called statusid defined with gettor/settor in parent view controller. [self.view addSubview:detailsVC.view]; In the child subview, I trying calling [super statusid:updatedValue]; to update statusid to a new value, but this creates an error. How can i update statusid in the parent? Anyone know how to do this? 回答1: with "super" you access your base class, the one your current class

MySql scoping problem with correlated subqueries

左心房为你撑大大i 提交于 2019-12-28 16:02:22
问题 I'm having this Mysql query, It works: SELECT nom ,prenom ,(SELECT GROUP_CONCAT(category_en) FROM (SELECT DISTINCT category_en FROM categories c WHERE id IN (SELECT DISTINCT category_id FROM m3allems_to_categories m2c WHERE m3allem_id = 37) ) cS ) categories ,(SELECT GROUP_CONCAT(area_en) FROM (SELECT DISTINCT area_en FROM areas c WHERE id IN (SELECT DISTINCT area_id FROM m3allems_to_areas m2a WHERE m3allem_id = 37) ) aSq ) areas FROM m3allems m WHERE m.id = 37 The result is: nom prenom

How can a variable be used when its definition is bypassed?

依然范特西╮ 提交于 2019-12-28 12:14:35
问题 In my mind, always, definition means storage allocation. In the following code, int i allocates a 4-byte (typically) storage on program stack and bind it to i , and i = 3 assigns 3 to that storage. But because of goto , definition is bypassed which means there is no storage allocated for i . I heard that local variables are allocated either at the entry of the function ( f() in this case) where they reside, or at the point of definition. But either way, how can i be used while it hasn't been

How to get all the variables available in a view in PHP?

独自空忆成欢 提交于 2019-12-28 09:16:10
问题 I need to see all the variables that are available in a view. I am a front end developer so I mostly work in the views directory. I don't always know which variables are being passed to the templates by the back end dev. Instead of asking him every time an easy solution would be some type of snippet that I can temporarily paste into the view that I'm working on so I can see all the available variables and even better if I can also see their types and values. I tried this: <pre><?php var_dump

How to get all the variables available in a view in PHP?

折月煮酒 提交于 2019-12-28 09:15:52
问题 I need to see all the variables that are available in a view. I am a front end developer so I mostly work in the views directory. I don't always know which variables are being passed to the templates by the back end dev. Instead of asking him every time an easy solution would be some type of snippet that I can temporarily paste into the view that I'm working on so I can see all the available variables and even better if I can also see their types and values. I tried this: <pre><?php var_dump

How do I give multiple JavaScript objects across multiple files access to same private variable?

安稳与你 提交于 2019-12-28 07:04:12
问题 If I want to span my JavaScript project across multiple source files, but have each file have access to the same private variable, how would one do that? For example, if I have the following code: APP = (function () { var _secret = {}, app = {}; // Application part 01: app.part01 = (function () { /* function that uses _secret */ }()); // Application part 02: app.part02 = (function () { /* function that uses _secret */ }()); // return app; }()); How do I put app.part01 and app.part02 in

javascript: Using the current for-loop counter-value inside a function() { }?

笑着哭i 提交于 2019-12-28 06:36:10
问题 on a website i want to do this: (simplified) myHandlers = new Array(); for(var i = 0; i < 7; i++) { myHandlers.push(new Handler({ handlerName: 'myHandler'+i, // works, e.g. ->myHandler1, 2, 3 etc. handlerFunc: function(bla) { /*...*/ alert(i); } // doesn't work,all return 7 } } I could set the counter as another attribute of my Handler (which would copy the current value) and use it inside my function, but I guess, there is also a way to actually copy this value, no? 回答1: When handlerFunc is