Code Newbie
News     Forums     Search     Members     Sign Up    

My Code Newbie
Username

Password

Articles/Snippets
ASP Classic
ASP.NET
C
C#
C++
HTML / CSS
Java
Javascript
Linux / BSD
Perl
PHP
Python
Ruby
SQL
VB 6
VB.NET

C.N. Friends
  Planet Rome

Link to Us!
Code Newbie
  Code Newbie
    forums
Old 02-26-2008, 11:53 PM   #1 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,503
sde is on a distinguished road
'this' in a prototype?

shouldn't i be able to assign object values to 'this' in a prototype of a js object? i think the answer is no since i'm asking this, but i need ideas on a different way to do this.

PHP Code:
function myclass(foobar) {
  
this.foo foo;
  
this.bar bar;
}

myclass.prototype.update(newfoonewbar) {
  
this.foo newfoo;
  
this.bar newbar;
}

// now i'll try it
var myobj = new myclass(00);

myobj.update(11);

// myobj.foo and myobj.bar still equal 0 here 
so, from a prototype, or any member function of a javascript class, how do i change a member property? this seems so basic.
__________________
Mike
sde is offline   Reply With Quote
Old 02-27-2008, 10:06 AM   #2 (permalink)
sde
Moderator
 
sde's Avatar
 
Join Date: May 2002
Location: us.ca
Posts: 4,503
sde is on a distinguished road
it was late and i was actually trying to set 'this' inside a jquery callback .. so this was representing the jquery object at that point in time. the code above probably works fine.
__________________
Mike
sde is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 06:05 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0 RC8





Copyright © 2000-2008, Milano Interactive
Web Hosting provided by Portal 360 Web Hosting