You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Mike Tutkowski <mi...@solidfire.com> on 2013/11/06 06:50:33 UTC

JavaScript Question

Hi,

Does anyone know why this checkbox of mine always returns false?

if ($isCustomizedIops.is(':checked')) {
    // do some stuff
}

That code is part of an event handler for a combobox (when the combobox
changes to a certain state, I want to see if the checkbox that is revealed
is in the checked state):

args.$select.change(function() {
    var $isCustomizedIops = $form.find('.form-item[rel=isCustomizedIops]');

    if ($isCustomizedIops.is(':checked')) {
        // do some stuff
    }
}

The checkbox is set up like this:

                                    isCustomizedIops: {
                                        label: 'label.custom.disk.iops',
                                        docID:
'helpDiskOfferingCustomDiskIops',
                                        isBoolean: true,
                                        isReverse: true,
                                        isChecked: false
                                    },

Thanks!

-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

Re: JavaScript Question - $isCustomizedIops.is(':checked')

Posted by Mike Tutkowski <mi...@solidfire.com>.
Thanks, Jessica! That did the trick. :)


On Wed, Nov 6, 2013 at 3:10 PM, Jessica Wang <Je...@citrix.com>wrote:

> Mike,
>
> Your $isCustomizedIops is something like:
>
> <div class="form-item">
>   <div class="name">
>     <label>Custom disk iops</label>
>   </div>
>   <div class="vale">
>     <input type=checkbox" checked="checked">
>   </div>
> </div>
>
> So, if you want to know whether the checkbox is checked or not, you should
> use
> "($isCustomizedIops.find('input[type=checkbox]').is(':checked')"
> instead of
> "($isCustomizedIops.is(':checked')"
>
> Jessica
>
>
> -----Original Message-----
> From: Mike Tutkowski [mailto:mike.tutkowski@solidfire.com]
> Sent: Wednesday, November 06, 2013 10:10 AM
> To: dev@cloudstack.apache.org
> Subject: Re: JavaScript Question
>
> This is just a guess, but I'm thinking if the checkbox is not visible, then
> ":checked" always returns false (which would be weird).
>
> I do make the checkbox visible before using ":checked", but it's possible
> this visibility change doesn't take effect until after the event handler
> finishes.
>
> Any thoughts on this from people who do a lot of JavaScript (or anyone
> else, of course). :)
>
>
> $isCustomizedIops.css('display', 'inline-block');
>
>                                                     if
> ($isCustomizedIops.is(':checked')) {
>                                                         $minIops.hide();
>                                                         $maxIops.hide();
>                                                     } else {
>
> $minIops.css('display', 'inline-block');
>
> $maxIops.css('display', 'inline-block');
>                                                     }
>
>
> On Tue, Nov 5, 2013 at 10:50 PM, Mike Tutkowski <
> mike.tutkowski@solidfire.com> wrote:
>
> > Hi,
> >
> > Does anyone know why this checkbox of mine always returns false?
> >
> > if ($isCustomizedIops.is(':checked')) {
> >     // do some stuff
> > }
> >
> > That code is part of an event handler for a combobox (when the combobox
> > changes to a certain state, I want to see if the checkbox that is
> revealed
> > is in the checked state):
> >
> > args.$select.change(function() {
> >     var $isCustomizedIops =
> $form.find('.form-item[rel=isCustomizedIops]');
> >
> >     if ($isCustomizedIops.is(':checked')) {
> >         // do some stuff
> >     }
> > }
> >
> > The checkbox is set up like this:
> >
> >                                     isCustomizedIops: {
> >                                         label: 'label.custom.disk.iops',
> >                                         docID:
> > 'helpDiskOfferingCustomDiskIops',
> >                                         isBoolean: true,
> >                                         isReverse: true,
> >                                         isChecked: false
> >                                     },
> >
> > Thanks!
> >
> > --
> > *Mike Tutkowski*
> > *Senior CloudStack Developer, SolidFire Inc.*
> > e: mike.tutkowski@solidfire.com
> > o: 303.746.7302
> > Advancing the way the world uses the cloud<
> http://solidfire.com/solution/overview/?video=play>
> > *(tm)*
> >
>
>
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the
> cloud<http://solidfire.com/solution/overview/?video=play>
> *(tm)*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*

RE: JavaScript Question - $isCustomizedIops.is(':checked')

Posted by Jessica Wang <Je...@citrix.com>.
Mike,

Your $isCustomizedIops is something like:

<div class="form-item">
  <div class="name">
    <label>Custom disk iops</label>
  </div>
  <div class="vale">
    <input type=checkbox" checked="checked">
  </div>
</div> 

So, if you want to know whether the checkbox is checked or not, you should use  
"($isCustomizedIops.find('input[type=checkbox]').is(':checked')"  
instead of 
"($isCustomizedIops.is(':checked')" 

Jessica


-----Original Message-----
From: Mike Tutkowski [mailto:mike.tutkowski@solidfire.com] 
Sent: Wednesday, November 06, 2013 10:10 AM
To: dev@cloudstack.apache.org
Subject: Re: JavaScript Question

This is just a guess, but I'm thinking if the checkbox is not visible, then
":checked" always returns false (which would be weird).

I do make the checkbox visible before using ":checked", but it's possible
this visibility change doesn't take effect until after the event handler
finishes.

Any thoughts on this from people who do a lot of JavaScript (or anyone
else, of course). :)


$isCustomizedIops.css('display', 'inline-block');

                                                    if
($isCustomizedIops.is(':checked')) {
                                                        $minIops.hide();
                                                        $maxIops.hide();
                                                    } else {

$minIops.css('display', 'inline-block');

$maxIops.css('display', 'inline-block');
                                                    }


On Tue, Nov 5, 2013 at 10:50 PM, Mike Tutkowski <
mike.tutkowski@solidfire.com> wrote:

> Hi,
>
> Does anyone know why this checkbox of mine always returns false?
>
> if ($isCustomizedIops.is(':checked')) {
>     // do some stuff
> }
>
> That code is part of an event handler for a combobox (when the combobox
> changes to a certain state, I want to see if the checkbox that is revealed
> is in the checked state):
>
> args.$select.change(function() {
>     var $isCustomizedIops = $form.find('.form-item[rel=isCustomizedIops]');
>
>     if ($isCustomizedIops.is(':checked')) {
>         // do some stuff
>     }
> }
>
> The checkbox is set up like this:
>
>                                     isCustomizedIops: {
>                                         label: 'label.custom.disk.iops',
>                                         docID:
> 'helpDiskOfferingCustomDiskIops',
>                                         isBoolean: true,
>                                         isReverse: true,
>                                         isChecked: false
>                                     },
>
> Thanks!
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
> *(tm)*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*(tm)*

Re: JavaScript Question

Posted by Mike Tutkowski <mi...@solidfire.com>.
This is just a guess, but I'm thinking if the checkbox is not visible, then
":checked" always returns false (which would be weird).

I do make the checkbox visible before using ":checked", but it's possible
this visibility change doesn't take effect until after the event handler
finishes.

Any thoughts on this from people who do a lot of JavaScript (or anyone
else, of course). :)


$isCustomizedIops.css('display', 'inline-block');

                                                    if
($isCustomizedIops.is(':checked')) {
                                                        $minIops.hide();
                                                        $maxIops.hide();
                                                    } else {

$minIops.css('display', 'inline-block');

$maxIops.css('display', 'inline-block');
                                                    }


On Tue, Nov 5, 2013 at 10:50 PM, Mike Tutkowski <
mike.tutkowski@solidfire.com> wrote:

> Hi,
>
> Does anyone know why this checkbox of mine always returns false?
>
> if ($isCustomizedIops.is(':checked')) {
>     // do some stuff
> }
>
> That code is part of an event handler for a combobox (when the combobox
> changes to a certain state, I want to see if the checkbox that is revealed
> is in the checked state):
>
> args.$select.change(function() {
>     var $isCustomizedIops = $form.find('.form-item[rel=isCustomizedIops]');
>
>     if ($isCustomizedIops.is(':checked')) {
>         // do some stuff
>     }
> }
>
> The checkbox is set up like this:
>
>                                     isCustomizedIops: {
>                                         label: 'label.custom.disk.iops',
>                                         docID:
> 'helpDiskOfferingCustomDiskIops',
>                                         isBoolean: true,
>                                         isReverse: true,
>                                         isChecked: false
>                                     },
>
> Thanks!
>
> --
> *Mike Tutkowski*
> *Senior CloudStack Developer, SolidFire Inc.*
> e: mike.tutkowski@solidfire.com
> o: 303.746.7302
> Advancing the way the world uses the cloud<http://solidfire.com/solution/overview/?video=play>
> *™*
>



-- 
*Mike Tutkowski*
*Senior CloudStack Developer, SolidFire Inc.*
e: mike.tutkowski@solidfire.com
o: 303.746.7302
Advancing the way the world uses the
cloud<http://solidfire.com/solution/overview/?video=play>
*™*