Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Do I have to check that an element exsist to get their properties?

Received: by 10.50.104.166 with SMTP id gf6mr1393727igb.1.1349268330338;
        Wed, 03 Oct 2012 05:45:30 -0700 (PDT)
X-BeenThere: mootools-users@googlegroups.com
Received: by 10.50.197.170 with SMTP id iv10ls3329676igc.4.gmail; Wed, 03 Oct
 2012 05:45:28 -0700 (PDT)
Received: by 10.66.75.39 with SMTP id z7mr526618pav.26.1349268328396;
        Wed, 03 Oct 2012 05:45:28 -0700 (PDT)
Received: by 10.66.75.39 with SMTP id z7mr526617pav.26.1349268328385;
        Wed, 03 Oct 2012 05:45:28 -0700 (PDT)
Return-Path: <christ...@gmail.com>
Received: from mail-pa0-f43.google.com (mail-pa0-f43.google.com [209.85.220.43])
        by gmr-mx.google.com with ESMTPS id g4si1036630pax.1.2012.10.03.05.45.28
        (version=TLSv1/SSLv3 cipher=OTHER);
        Wed, 03 Oct 2012 05:45:28 -0700 (PDT)
Received-SPF: pass (google.com: domain of christ...@gmail.com designates 209.85.220.43 as permitted sender) client-ip=209.85.220.43;
Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of christ...@gmail.com designates 209.85.220.43 as permitted sender) smtp.mail=christ...@gmail.com; dkim=pass header...@gmail.com
Received: by padfb1 with SMTP id fb1so9149734pad.16
        for <mootools-users@googlegroups.com>; Wed, 03 Oct 2012 05:45:28 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20120113;
        h=mime-version:in-reply-to:references:date:message-id:subject:from:to
         :content-type;
        bh=WsLys+cIgwkHBF1mIOM9Bo4VvZX14wqEyeSuFVlk5es=;
        b=S7b/PD+6aKjuseuMNhK5YE4r4aAxmpDqJ4h9sr1Ob7q2cuNqy2NGeMutY3wsCU/BGu
         4EKI72sfZCdSh26ib2LPlotBgbCUKM2SFlfPCdxkDefYFcGZlLgRHV9dZvflyWIsWohG
         K7veTG8Z0lkbtg8tjtkdg2o8B1CuGc9vbogu0HuTcL1TtCFC28qKpmb4pBNYD2KRR3rP
         hEXhwVCboJAPTZuIkUYRJ5WcNDRfHGFITDAWV4eoRCs8DErL1t+NmxrffVanVsKTDRBF
         9pu47jJ5vBytOmpPUx8Nh523QGbumTNxJllDWddftRd3EGFJIdLY+ae35wcIfxXADJ9H
         otZA==
MIME-Version: 1.0
Received: by 10.66.81.103 with SMTP id z7mr4761200pax.57.1349268327976; Wed,
 03 Oct 2012 05:45:27 -0700 (PDT)
Received: by 10.68.229.229 with HTTP; Wed, 3 Oct 2012 05:45:27 -0700 (PDT)
In-Reply-To: <CAAYg7pBPP-0=vBt1pcRAr9PcKsVeAhPKv7h7sd9iKaDgqYH...@mail.gmail.com>
References: <22f15b7f-bcb4-40a9-9837-e654ab471e65@googlegroups.com>
	<CAAYg7pBPP-0=vBt1pcRAr9PcKsVeAhPKv7h7sd9iKaDgqYH...@mail.gmail.com>
Date: Wed, 3 Oct 2012 13:45:27 +0100
Message-ID: <CAPOHBTU8uCh7Prj1WOAwO1sRfvApReUGhxUFAz4NgLRQ-Md...@mail.gmail.com>
Subject: Re: [Moo] Do I have to check that an element exsist to get their properties?
From: Dimitar Christoff <christ...@gmail.com>
To: mootools-users@googlegroups.com
Content-Type: text/plain; charset=ISO-8859-1

you can be lazy and do:

var prop = thisl.getElements('a').get('href').getLast();

it's not the most performant.

On 3 October 2012 11:39, Arian Stolwijk <stolwijk.ar...@gmail.com> wrote:
> $() and .getElement() can return null if the element doesn't exist.
> So if you're not sure the element exists, you'll have to check it indeed
> with an if statement.
>
>
> On Wed, Oct 3, 2012 at 12:36 PM, Hamburger <bilidi...@web.de> wrote:
>>
>> Hello,
>> please let me have one more beginner question.
>> With the following test I will get an error if the 'a' - element doesnt
>> exsist.
>> var test = this.getElement("a").get("href");
>>
>> What I would like to have is a 'null' or 'undefined'
>>
>> Do I have todo it realy like this:
>> var test = this.getElement("a");
>> if (test) {test=test.get("href");}
>>
>> or is there a shorter other way to do this.
>
>



-- 
Dimitar Christoff

"JavaScript is to JAVA what hamster is to ham"
@D_mitar - https://github.com/DimitarChristoff