Bug Tracker

Modify

Ticket #10143 (closed bug: invalid)

Opened 21 months ago

Last modified 21 months ago

Checkboxes can't be checked with .toggle(function, function)

Reported by: info@… Owned by:
Priority: low Milestone: None
Component: event Version: 1.6.2
Keywords: Cc:
Blocking: Blocked by:

Description

When I click the checkbox on this page with my mouse the callbacks are fired but the checkbox isn't checked, I assume that preventDefault is being called somewhere but shouldn't be.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
</head>
<body>
    <form>
        <input type="checkbox" id="foo" value="bar" name="baz" />
    </form>
    <script type="text/javascript">
    $(document).ready(function() {
        $('#foo').toggle(
            function() {
                console.log('toggled 1');
            },
            function() {
                console.log('toggled 2');
            }
        );
    });
    </script>
</body>
</html>

Change History

comment:1 Changed 21 months ago by info@…

This shows the problem  http://jsfiddle.net/bWQMD/14/

comment:2 Changed 21 months ago by timmywil

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to event

This is the intended behavior. From the docs: "The implementation also calls .preventDefault() on the event, so links will not be followed and buttons will not be clicked if .toggle() has been called on the element."

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.