Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

Javascript variable scope issue

Issue I have a simple scoping issue that is eluding me. Here is a simpler version of the code but employs the same principle. function myFunction(){ $(‘.selector_1, .selector_2’).click(function(e){ var $trgt = $(e.target); var myVAR; if ($trgt.is(‘.selector_1’)){ myVAR = ‘selector_1’; }

Continue reading

in-clause scoping

Issue I am doing some work for a company that has SQL Server 2008. One of their stored procedures references (or appears to reference) a column that does not exist, and yet there is no error. The query has this

Continue reading

Why is my jQuery variable empty?

Issue I am new to jQuery and I ran into a problem that is probably easy to spot for most of the frontend gurus out here. I created the following script $(document).ready(function() { $(“#facet_properties input[type=’checkbox’]”).each(function() { $(this).click(function() { var queryString

Continue reading

Strange fold scoping issue

Issue I ran into this head scratcher while debugging a transactional query block. For some reason, despite the connection rollback occurring in the fold left/fail operation, success/right outcomes were getting rolled back as well. Example: // returns Either[String, Int] db.handle

Continue reading

Scoping in javascript

Issue <html> <head> <title></title> <script type=”text/javascript”> var a = 1; function b() { a = 10; return; function a() {} } </script> </head> <body> <script type=”text/javascript”> b(); alert(a); </script> </body> </html> I am coming from c and java background .

Continue reading

Model fitting functions and environemnts

Issue Here is a kind of minimal example for a problem I stumbled upon: mylm <- function(formula,data,subset=NULL){ mysubset <- subset # some other clever manipulation lm(formula,data,mysubset) } mydata <- data.frame(x=rnorm(10),y=rnorm(10)) mylm(y~x,mydata) # this fails! The reason why the last line

Continue reading

Weird scope behavior in node or am I sleeping?

Issue My js is as follows, /* * GET home page. */ var MongoClient = require(‘mongodb’); exports.index = function(req, res){ var studentObj = {}; MongoClient.connect(“mongodb://localhost:27017/MY_DB_TEST”, function(err, db) { if(!err) { console.log(“We are connected”); var collection = db.collection(‘test’); var stream =

Continue reading

Python scoping problem

Issue I have a trivial example: def func1(): local_var = None def func(args): print args, print “local_var:”, local_var local_var = “local” func(“first”) func(“second”) func1() I expect the output to be: first local_var: None second local_var: local However, my actual output

Continue reading

Javascript Odd Scoping Behavior

Issue I’ve been going through Javascript function scope and have run into this: var scope = “global”; function f(){ console.log(scope); var scope = “local”; console.log(scope); } f(); Now I understand that the output of the first log is “undefined” because

Continue reading

Cant access variable inside jQuery $.post

Issue I went through many posts about this, but didnt find any solution working for me – cleaned up code: $(‘#form-new’).submit(function(e){ e.preventDefault(); $curForm = $(this); $textbox = $( ‘.new-box’ ,this); window.tmp_input_ok = false; var wasError = false; if( $.trim($textbox.val()) ==

Continue reading

Javascript scope issue

Issue I thought I understood how javascript scope worked until now. This is what I have function MFCommentsHandler(node, type, item) { this.get = function(returnType){ … } function getButton(){ var button = document.createElement(‘button’), get = this.get; button.innerHTML = ‘Load more comments’;

Continue reading

Php class not allowing class-wide scoping

Issue I can’t figure out the below code, why it isn’t working. /classes/ContentManager.php <?php class ContentManager{ protected $sql; protected $host = “<correct host>”; protected $username = “<correct username>”; protected $password = “<correct password”; protected $dbname = “<correct dbname>”; protected $query;

Continue reading

Environments in R Shiny

Issue At http://shiny.rstudio.com/articles/scoping.html the rules for scoping in shiny are well explained. There are 3 environments or levels nested inside each other: objects available within a function, within a session and within all sessions. Using <- will change the object

Continue reading

Variable Scoping in Python

Issue Currently, I’m writing a simple Python program for doing the k-medians clustering, however I encountered a problem which I thought related to the variable scoping. Here is my clustering method class Cluster(object): center = None points = [] def

Continue reading