Martin rote:
> The following snippet shows how I've created my inheritance structure.
> I got inspired by this article.
>
> http://www.kevlindev.com/tutorials/javascript/inheritance/inheritance...
>
> Code snippet:http://jsfiddle.net/v5x6w/1/
> [ ... ]
> The base contructor is inadvertently called twice.

Jake is correct that the the call to `new Base()` is what's causing
your problem.  I disagree, though, that this is an inappropriate way
to do inheritance.  Their are plenty of reasonable techniques,
including this one.  But you have to watch what you're doing.  With
this technique, you probably don't want to cause any side-effects in
the constructor.  If you notice the later examples in Kevin Lindsey's
page, he checks the number of parameters before calling his init
method.  You could do something similar in your code with an `if`
block:

    Base.prototype.init = function (name) {
      if (name) {
        var url = "/url/" + name;
        alert(url);
        $("div1").load(url);
      }
    };

-- 
To view archived discussions from the original JSMentors Mailman list: 
http://www.mail-archive.com/[email protected]/

To search via a non-Google archive, visit here: 
http://www.mail-archive.com/[email protected]/

To unsubscribe from this group, send email to
[email protected]

Reply via email to