Hi Micheal,

You've probably already sorted this, but:

<code>
<script>
$('.checkbox').click(function(e) {
        e.stopPropagation();
        var action=$(this).attr('checked') ? 'checkbox: you checked it' :
'checkbox: you unchecked it'
        alert(action)
});
$('.myrow').click(function(e) {
        if (e.target.type != 'checkbox') {
                // $('input:checkbox', this).trigger('click');
                var action=$(this).attr('checked') ? ' myrow: you checked it' :
'myrow: you unchecked it';
                $('#row1checkbox').attr('checked', !$
('#row1checkbox').attr('checked'));
                alert(action);
        }
});
</script>
</code>

Regards

P

On Sep 9, 3:20 pm, Wooty <[EMAIL PROTECTED]> wrote:
> Hi Michael,
>
> Have you checked out the stopPropagation() method for events?
>
> eg:
> $(check_id).click(function(e){
>    e.stopPropagation();
>
> });
>
> This may help - I have used this on a clickable image on a table row
> to stop the click expanding / contracting the table row.
>
> Cheers
>
> P
>
> On Sep 9, 2:59 pm, "Michael Smith" <[EMAIL PROTECTED]> wrote:
>
> > Except ... (sorry to come back on this one)
>
> > I'm trying to do something else ('growl' actually but that's not
> > important for the purposes of the issue) when the user checks/unchecks
> > the box
>
> >http://dev2.savingforchildren.co.uk/mjs/row_select_2.epl
>
> > As this demo now shows, when you check the box itself it does what
> > would be expected.  But when you click somewhere on the row, the
> > checked attribute doesn't actually get set (or at least not at this
> > point).
>
> > Thanks
>
> > Michael
>
> > On Tue, Sep 9, 2008 at 11:17 AM, Michael Smith <[EMAIL PROTECTED]> wrote:
> > > Thank you - this seemed the neatest solution and worked nicely for me.
>
> > > Michael
>
> > > On Tue, Sep 9, 2008 at 12:53 AM, Karl Swedberg <[EMAIL PROTECTED]> wrote:
> > >> Hi Michael,
> > >> You could do it a little differently. This should work:
> > >> $('.myrow').click(function(event) {
> > >>   if (event.target.type != 'checkbox') {
> > >>     $('input:checkbox', this).trigger('click');
> > >>   }
> > >> });
> > >> so, when the user clicks somewhere in the row, if the click isn't 
> > >> directly
> > >> on a checkbox, it triggers a click for that row's checkbox.
> > >> --Karl
> > >> ____________
> > >> Karl Swedberg
> > >>www.englishrules.com
> > >>www.learningjquery.com
>
> > >> On Sep 8, 2008, at 4:18 PM, Michael Smith wrote:
>
> > >> Thanks for the reply.
>
> > >> I added a return false;
>
> > >>http://dev.savingforchildren.co.uk/mjs/row_select_2.epl
>
> > >> But it doesn't seem to make any difference.
>
> > >> Am I missing something?
>
> > >> Thanks again
>
> > >> Michael
>
> > >> On Mon, Sep 8, 2008 at 7:18 PM, Danny <[EMAIL PROTECTED]> wrote:
>
> > >> add " return false; " to your click handler to keep the click from
>
> > >> getting to the checkbox itself.
>
> > >> Danny
>
> > >> On Sep 8, 10:55 am, "Michael Smith" <[EMAIL PROTECTED]> wrote:
>
> > >> Hi there,
>
> > >> I'm trying to make a page which automatically toggles a checkbox when
>
> > >> you click anywhere on the row.
>
> > >> Here's a version I've cut down to the bare bones to illustrate
>
> > >>http://dev.savingforchildren.co.uk/mjs/row_select.epl
>
> > >> It seems to work fine unless the user actually clicks on the checkbox
>
> > >> itself.  In this case it seems that it actually gets toggled twice and
>
> > >> so reverts to its original state.
>
> > >> Any suggestions on the cleanest / simples way to avoid this? (I can
>
> > >> think of a few messy ways)
>
> > >> Thanks
>
> > >> Michael

Reply via email to