Search Results

Search found 4509 results on 181 pages for 'scope chain'.

Page 7/181 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • jquery scope issue

    - by matthewb
    I am having issue with the following: I can't seem to keep the link I am selecting in each repeated item. The word "this" is getting lost. the Var event_id works for each element, but the var $something is undefined? Why is that, Ideally I wanted to do a switch statement but same issue, can't seem to get it to know what link I click and the elements around it to do the action. Updated Full Function: function rsvp (selector,function_url) { $(selector).livequery('click',function(){ var $select = $(selector).attr('rel'); var $event_id= $(this).parents('ul.event-options').attr('rel'); if ($select == "attending") { $(this).closest('span.rsvp-status').html("I'm Attending &ndash; <a href='javascript:;' class='remove' rel='remove'>Remove</a>"); var $something = $(this).parents('ul.event-options').attr('rel'); alert($something); } if ($select == "remove") { $(this).closest('span.rsvp-status').html("Not Attending &ndash; <a href='javascript:;' class='rsvp' rel='attending'>RSVP?</a>"); } if ($select == "interested") { $(this).closest('li').addClass('interested'); $(this).closest('li').removeClass('not-interested'); $(this).closest('li').html("You're Interested"); } $.ajax({ type: "POST", url: "/events/set_member/"+function_url, data: "event_id="+$event_id, beforeSend: function() { $("<span class='notice'>Updating...</span>").prependTo('body'); }, complete: function() { $('span.notice').fadeOut(500); } }); }); } rsvp ('a.rsvp','rsvp'); rsvp ('a.interests','interested'); rsvp ('a.remove','remove'); HTML <ul class="event-options" rel="<?=$event['event_id']?>"> <?php if($event['rsvp_total'] > 0) { ?> <!-- Show Only When Count is Greater than 0 --> <li class="group"><span class="total"><?= $event['rsvp_total']?></span>Interested </li> <?php } ?> <li class="rsvp"><span class="rsvp-status"> Not Attending &ndash; <a href="javascript:;" class="rsvp" rel="attending">RSVP?</a></span></li> <li class="not-interested"> <a href="javascript:;" class="interests" rel="interested"> Interested? </a> </li> <li class="place"><span><a href="<?=$place_path.$event['place_id']?>"><?=$event['place_name']?></a></span></li> <li class="share" rel="<?=$event['event_name']?>"> <a class="sharethis"></a> </li> </ul>

    Read the article

  • Scope of "library" methods

    - by JS
    Hello, I'm apparently laboring under a poor understanding of Python scoping. Perhaps you can help. Background: I'm using the 'if name in "main"' construct to perform "self-tests" in my module(s). Each self test makes calls to the various public methods and prints their results for visual checking as I develop the modules. To keep things "purdy" and manageable, I've created a small method to simplify the testing of method calls: def pprint_vars(var_in): print("%s = '%s'" % (var_in, eval(var_in))) Calling pprint_vars with: pprint_vars('some_variable_name') prints: some_variable_name = 'foo' All fine and good. Problem statement: Not happy to just KISS, I had the brain-drizzle to move my handy-dandy 'pprint_vars' method into a separate file named 'debug_tools.py' and simply import 'debug_tools' whenever I wanted access to 'pprint_vars'. Here's where things fall apart. I would expect import debug_tools foo = bar debug_tools.pprint_vars('foo') to continue working its magic and print: foo = 'bar' Instead, it greets me with: NameError: name 'some_var' is not defined Irrational belief: I believed (apparently mistakenly) that import puts imported methods (more or less) "inline" with the code, and thus the variable scoping rules would remain similar to if the method were defined inline. Plea for help: Can someone please correct my (mis)understanding of scoping regards imports? Thanks, JS

    Read the article

  • Rails Named Scope and overlapping conditions

    - by Tumtu
    Hi everyone, have a question about rails SQL generation: class Organization < ActiveRecord::Base has_many :people named_scope :active, :conditions => { :active => 'Yes' } end class Person < ActiveRecord::Base belongs_to :organization end Rails SQL for all active people in the first organiztion Organization.first.people.active.all [4;36;1mOrganization Load (0.0ms)[0m [0;1mSELECT TOP 1 * FROM [organizations] [0m [4;35;1mPerson Load (0.0ms)[0m [0mSELECT * FROM [people] WHERE ((([people].[active] = 'Yes') AND ([people].organization_id = 1)) AND ([people].organization_id = 1)) [0m Why Rails generates "[people].organization_id = 1" condition twice ? Does someone know how to make it DRY ? e.g. SELECT * FROM [people] WHERE (([people].[active] = 'Yes') AND ([people].organization_id = 1))

    Read the article

  • PHP scope question

    - by Dan
    Hi, I'm trying to look through an array of records (staff members), in this loop, I call a function which returns another array of records (appointments for each staff member). foreach($staffmembers as $staffmember) { $staffmember['appointments'] = get_staffmember_appointments_for_day($staffmember); // print_r($staffmember['appointments'] works fine } This is working OK, however, later on in the script, I need to loop through the records again, this time making use of the appointment arrays, however they are unavailable. foreach ($staffmembers as $staffmember) { //do some other stuff //print_r($staffmember['appointments'] no longer does anything } Normally, I would perform the function from the first loop, within the second, however this loop is already nested within two others, which would cause the same sql query to be run 168 times. Can anyone suggest a workaround? Any advice would be greatly appreciated. Thanks

    Read the article

  • Property Scope (Iphone)

    - by Hank
    Hello All. I am having trouble accessing a declared property and I think I am missing something fundamental about the nature of properties and perhaps view controllers. Here's what I'm doing so far: declaring a property "myPhone" in a root view controller called RootViewController. grabbing a phone number from a modally presented people picker setting "myPhone" to the value from the people picker (from within shouldContinueAfterSelectingPerson of ABPeoplePickerNavigationController) trying to access "myPhone" from another modally presented view controller "myPhone" continues to NSLog to null despite trying every permutation of self.myPhone, super, RootViewController, etc. to try and access the value I set. What am I missing?

    Read the article

  • C pointer array scope and function calls

    - by juvenis
    I have this situation: { float foo[10]; for (int i = 0; i < 10; i++) { foo[i] = 1.0f; } object.function1(foo); // stores the float pointer to a const void* member of object } object.function2(); // uses the stored void pointer Are the contents of the float pointer unknown in the second function call? It seems that I get weird results when I run my program. But if I declare the float foo[10] to be const and initialize it in the declaration, I get correct results. Why is this happening?

    Read the article

  • Javascript: Access the right scope "under" apply(...)

    - by Chau
    This is a very old problem, but I cannot seem to get my head around the other solutions presented here. I have an object function ObjA() { var a = 1; this.methodA = function() { alert(a); } } which is instantiated like var myObjA = new ObjA(); Later on, I assign my methodA as a handler function in an external Javascript Framework, which invokes it using the apply(...) method. When the external framework executes my methodA, this belongs to the framework function invoking my method. Since I cannot change how my method is called, how do I regain access to the private variable a? My research tells me, that closures might be what I'm looking for.

    Read the article

  • jQuery variables and scope

    - by Peuge
    I am writing a jQuery plugin and am running into a few problems with regard to variables. For example I have the following skeleton structure for my plugin, which is going to act on a textbox. In my init function I want to set a variable and bind a keypress event to my textbox. That keypress event needs to call another function, in which I need the variable. Is this possible? (function($){ var methods = { init : function(options){ return this.each(function(){ var $this = $(this); var someVar = 'somevar'; $this.keypress(function(event){ //I want to call my customFunction }); }); }, customFunction : function(){ //I am wanting to access 'someVar' here }; $.fn.mynamespace = function(method){ //handle which method to call here }; })(jQuery); Many thanks in advance.

    Read the article

  • How do I scope variables properly in jQuery?

    - by safetycopy
    I'm working on a jQuery plugin, but am having some trouble getting my variables properly scoped. Here's an example from my code: (function($) { $.fn.ksana = function(userOptions) { var o = $.extend({}, $.fn.ksana.defaultOptions, userOptions); return this.each(function() { alert(rotate()); // o is not defined }); }; function rotate() { return Math.round(o.negRot + (Math.random() * (o.posRot - o.negRot))); }; $.fn.ksana.defaultOptions = { negRot: -20, posRot: 20 }; })(jQuery); I'm trying to get the private function rotate to be able to see the o variable, but it just keeps alerting 'o is not defined'. I'm not sure what I'm doing wrong.

    Read the article

  • Basic Python: Exception raising and local variable scope / binding

    - by SuperJdynamite
    I have a basic "best practices" Python question. I see that there are already StackOverflow answers tangentially related to this question but they're mired in complicated examples or involve multiple factors. Given this code: #!/usr/bin/python def test_function(): try: a = str(5) raise b = str(6) except: print b test_function() what is the best way to avoid the inevitable "UnboundLocalError: local variable 'b' referenced before assignment" that I'm going to get in the exception handler? Does python have an elegant way to handle this? If not, what about an inelegant way? In a complicated function I'd prefer to avoid testing the existence of every local variable before I, for example, printed debug information about them.

    Read the article

  • Variable scope problem in JavaScript

    - by dfjhdfjhdf
    I declare a variable with the var word inside a function that handles Ajax requests, then later on in the function I have another function that should change the value of the variable but - my problem - it fails. How to settle the problem down? Here's similiar code I use: function sendRuest(someargums) { /* some code */ var the_variable; /* some code */ //here's that other function request.onreadystatechange = function() { if (request.readyState == 4) { switch (request.status) { case 200: //here the variable should be changed the_variable = request.responseXML; /* a lot of code */ //somewhere here the function closes } return the_variable; } var data = sendRequest(someargums); //and trying to read the data I get the undefined value

    Read the article

  • Global JavaScript Variable Scope: Why doesn't this work?

    - by CoryDorning
    So I'm playing around with JavaScript and came across what I think to be an oddity. Is anyone able to explain the following? (i've included the alerted values as comments) Why is the first alert(msg) inside foo() returning undefined and not outside? var msg = 'outside'; function foo() { alert(msg); // undefined var msg = 'inside'; alert(msg); // inside } foo(); alert(msg); // outside Considering these both work fine: var msg = 'outside'; function foo() { alert(msg); // outside } alert(msg); // outside and: var msg = 'outside'; function foo() { var msg = 'inside'; alert(msg); // inside } alert(msg); // outside

    Read the article

  • Accessing variables with different scope in C++

    - by Portablejim
    With #include <iostream> using namespace std; int a = 1; int main() { int a = 2; if(true) { int a = 3; cout << a << " " << ::a // Can I access a = 2 here? << " " << ::a << endl; } cout << a << " " << ::a << endl; } having the output 3 1 1 2 1 Is there a way to access the 'a' equal to 2 inside the if statement where there is the 'a' equal to 3, with the output 3 2 1 2 1 Note: I know this should not be done (and the code should not get to the point where I need to ask). This question is more "can it be done".

    Read the article

  • Android Static Variable Scope and Lifetime

    - by Edison
    I have an application that has a Service uses a ArrayList to store in the background for a very long time, the variable is initialized when the service started. The service is in the background and there will be frequent access to the variable (that's why i don't want to use file management or settings since it will be very expensive for a file I/O for the sake of battery life). The variable will likely to be ~1MB-2MB over its life tie. Is it safe to say that it will never be nulled by GC or the system or is there any way to prevent it? Thanks.

    Read the article

  • Coffeescript getting proper scope from callback method

    - by pandabrand
    I've searched for this and can't seem to find an successful answer, I'm using a jQuerey ajax call and I can't get the response out to the callback. Here's my coffeescript code: initialize: (@blog, @posts) -> _url = @blog.url _simpleName = _url.substr 7, _url.length _avatarURL = exports.tumblrURL + _simpleName + 'avatar/128' $.ajax url: _avatarURL dataType: "jsonp" jsonp: "jsonp" (data, status) => handleData(data) handleData: (data) => console.log data @avatar = data Here's the compiled JS: Blog.prototype.initialize = function(blog, posts) { var _avatarURL, _simpleName, _url, _this = this; this.blog = blog; this.posts = posts; _url = this.blog.url; _simpleName = _url.substr(7, _url.length); _avatarURL = exports.tumblrURL + _simpleName + 'avatar/128'; return $.ajax({ url: _avatarURL, dataType: "jsonp", jsonp: "jsonp" }, function(data, status) { return handleData(data); }); }; Blog.prototype.handleData = function(data) { console.log(data); return this.avatar = data; }; I've tried a dozen variations and I can't figure out how to write this? Thanks.

    Read the article

  • Oracle Value Chain Summit - February, 2012 Hold The Date!

    - by paul.homchick
    The Oracle Value Chain Summit brings together all of the Oracle Supply Chain products, including Product Lifecycle Management, Manufacturing, Enterprise Asset Management, Logistics,Value Chain Planning and Procurement Summit to create a comprehensive conference that includes over 200 sessions covering the entire value chain footprint. The marquee value chain event of the year, the Oracle Value Chain Summit will bring customers, partnersand industry experts together to exchange views and demonstrate the latest tools that create more connectedand efficient value chains. The Summit will focus on today’s key supply chain management challenges and feature hands-on workshops and solution demonstrations. Join us at the Hyatt Regency Embarcadero in San Francisco, February 4th through 6th. Follow this link for more information and to register for the event. Don't delay! This event is sure to sell out. 

    Read the article

  • How can I timeout Client-scoped variables in Coldfusion?

    - by Joshua Carmody
    I apologize if this is a "duh" question. It seems like the answer should be easily googleable, but I haven't found it yet. I am working on a large Coldfusion application that stores a large amount of session/user data in the Client scope (ie <cfset Client.UserName = "JoshuaC"> ). I did not write this application, and I don't have the luxury of significantly refactoring it. I've been given the task of setting the Client variables to time out after 72 hours. I'm not entirely sure how to do this. If I had written the application, I would have stored the variables in the Session scope, and then changed the sessiontimeout attribute of the CFAPPLICATION tag. As it is though, I'm not sure if that timeout affects the Client variables, or what their level of persistence is. The way the application works now, the Client variables never time out, and only clearing the user's cookies, or visiting a logout page which sets all the Client-scoped application variables to "", will clear the values. Of course, I could create some kind of timestamp variable like Client.LastAccessDateTime, and put something in the Application.cfm to clear the client variables if that datetime is more than 72 hours prior to Now(). But there's got to be a better way, right?

    Read the article

  • What is the JavaScript variable scope in a switch / case statment?

    - by Todd Moses
    While creating JavaScript with ASP.NET MVC I noticed several scope warnings and realized that I am missing something with understanding the variable scope inside the switch / case statement. Warning: 'i' is already defined referring to case b and case c My code looks similar to this: switch(element) { case 'a': for(var i=0; i < count; i++){ do something } break; case 'b': for(var i=0; i < count; i++){ do something } break; case 'c': for(var i=0; i < count; i++){ do something } break; } I thought scope ended with each break statement but it seems that scope does not end until the end of the switch/case. Is scope for the entire switch/case?

    Read the article

  • New Best-in-Class Solutions in Supply Chain Planning - Part 2

    Hear Nadeem Syed, Oracle Group Vice President, Advanced Planning Products discusst Oracle's recently announced best-in-class Supply Chain Planning solutions: Advanced Planning Command Center, Demand Signal Repository, Spare Parts Planning and Manufacturing Operations Center. Gain an understanding of the capabilities of these ground-breaking planning solutions and what types of enterprises can benefit from them.

    Read the article

  • New Best-in-Class Solutions in Supply Chain Planning - Part 1

    Hear Nadeem Syed, Oracle Group Vice President, Advanced Planning Products discusst Oracle's recently announced best-in-class Supply Chain Planning solutions: Advanced Planning Command Center, Demand Signal Repository, Spare Parts Planning and Manufacturing Operations Center. Gain an understanding of the capabilities of these ground-breaking planning solutions and what types of enterprises can benefit from them.

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >