Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

prototype object creating problem...

Status
Not open for further replies.

oikonen

Programmer
May 2, 2011
1
FI
Can anybody tell why the new object creating method don't work in my test code? The "old" way seems working just ok.
The prototype framework is 1.7.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "<html xmlns="<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="js/prototype.js"></script>

<script type="application/javascript">
<!--

/* obsolete syntax, working just fine. */
var ProgressBar1 = Class.create();
ProgressBar1.prototype =
{
initialize: function(Container) {
this.Container = Container;
},
showProp: function() {
alert(this.Container);
}
};

/* new syntax, not working? */
var ProgressBar2 = Class.create({
initialize: function(Container) {
this.Container = Container;
},
showProp: function() {
alert(this.Container);
}
});

-->
</script>
</head>

<body>

<div id="progBar1"></div>
<div id="progBar2"></div>

<script type="application/javascript">
<!--

var progress1 = new ProgressBar1($("progBar1"));
var progress2 = new ProgressBar2($("progBar2"));

progress1.showProp();
progress2.showProp();

-->
</script>

</body>
</html>


Am i really that stupid 'cause i don't find error in this snippet...

Olli.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top