473,505 Members | 14,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Prototype error's

43 New Member
i i tryed to explore jQuery because its build from prototypes so i made script like that
Expand|Select|Wrap|Line Numbers
  1. var TaderDOM = window.TaderDOM = window.$ = function(element) { 
  2.     return new TaderDOM.fn.init(element); 
  3. };
  4.  
  5. TaderDOM.fn = {
  6.     init: function(element) { 
  7.         return document.getElementById(element); 
  8.     },
  9.     html: function() {
  10.         return "working";
  11.     }
  12. };
  13. TaderDOM.fn.init.prorotype = TaderDOM.fn;
  14.  
when i call $(element).html(); it should return me working but it don't why?
Jun 13 '08 #1
2 1266
rnd me
427 Recognized Expert Contributor
i i tryed to explore jQuery because its build from prototypes so i made script like that
Expand|Select|Wrap|Line Numbers
  1. var TaderDOM = window.TaderDOM = window.$ = function(element) { 
  2.     return new TaderDOM.fn.init(element); 
  3. };
  4.  
  5. TaderDOM.fn = {
  6.     init: function(element) { 
  7.         return document.getElementById(element); 
  8.     },
  9.     html: function() {
  10.         return "working";
  11.     }
  12. };
  13. TaderDOM.fn.init.prorotype = TaderDOM.fn;
  14.  
when i call $(element).html(); it should return me working but it don't why?
because new TaderDOM.fn.init(element) returns an object, the element.

the html() function you want is one dot to the left, on TaderDOM.fn.
other than being stored in the same object, init and html bear no inherit relation ship to each other.
you are essentially just pointing to the function init as any other variable.

you could add .html() to, say, Object's prototype (some will cringe), or create a constructor function, and add .html() to it's prototype.
Jun 14 '08 #2
tader
43 New Member
so i did script like this and i has one problem when i call $(element) it don't returns the element how i should if i put return statement in init function all script brakes how to do that when i put return statement the script wouldn't broke
Expand|Select|Wrap|Line Numbers
  1. var TaderDOM = window.TaderDOM = window.$ = function(element) { return new TaderDOM.fn.init(element); };
  2.  
  3. TaderDOM.fn = {
  4.     Object: new Object,
  5.     init: function(element) { 
  6.         TaderDOM.fn.Object = document.getElementById(element);
  7.     },
  8.     html: function() {
  9.         return this.Object.innerHTML;    
  10.     }
  11. };
  12.  
  13. TaderDOM.fn.init.prototype = TaderDOM.fn;
  14.  
Jun 14 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

21
3807
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
23
2407
by: Allin Cottrell | last post by:
Thomas Heinz wrote (in re. gcc compilation of this erroneous program): $ cat test.c int f(int); int f(); int f() {return 0;} int main (void) { return 0; }
13
2525
by: eman1000 | last post by:
I was recently looking at the prototype library (http://prototype.conio.net/) and I noticed the author used the following syntax: Object.extend(MyObj.prototype, { my_meth1: function(){},...
6
1468
by: mmcloughlin | last post by:
I'm learning about objects and am trying to figure out how basic inheritance works. I've got into the habit of explicitly setting the prototype object with an object literal as it seems to make the...
6
1854
by: burningodzilla | last post by:
Hi all - I'm preparing to dive in to more complex application development using javascript, and among other things, I'm having a hard time wrapping my head around an issues regarding "inheritance"...
3
1793
by: mike_solomon | last post by:
I am trying to use prototype.js to log javascript errors among other things but by including <script type="text/javascript" src="prototype.js"></scriptin my page some of my existing javascript...
6
2531
by: libsfan01 | last post by:
Hi all Im trying to use prototype for an xmlhttprequest, but it doesn't seem to be working cross-browser. Is there someway of getting it to be IE6 compatible (active x)? here's my code so...
11
1748
by: webgour | last post by:
Hello, I am wondering why the following works, on IE6, but with an error : "Not implemented". function TEST(){} TEST.prototype.Initialize = function() { var mImage = new Image(); var mDate...
83
4109
by: liketofindoutwhy | last post by:
I am learning more and more Prototype and Script.aculo.us and got the Bungee book... and wonder if I should get some books on jQuery (jQuery in Action, and Learning jQuery) and start learning about...
2
6445
by: hzgt9b | last post by:
I know how to overwrite a function. Normally this is what I would do: function someFunction() { /* orig definition here */ } //later in the execution stream I would do... someFunction = function...
0
7216
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7303
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7367
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7018
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5613
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1528
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.