Skip to main content

Bug Tracker

Side navigation

#14324 closed bug (notabug)

Opened September 03, 2013 02:45AM UTC

Closed September 10, 2013 07:54PM UTC

jquery.trigger will make a looped calling

Reported by: aiqunfang@163.com Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:
Description

there will cause a looped calling in show method.

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <script type="text/javascript" src="jquery10.js"></script>
    <script type="text/javascript">


        function MyType() {
            var this$ = $(this), times = 0;
            this.show = function () {
                times++;
                this$.trigger("show", this); // will make a looped calling, should i use "onshow" for type name of event? but type name for click of html element is "click"
                $("#btn").val(times); // invalid, it is not 1
            }
        }

    </script>
</head>
<body>
    <input id="btn" type="button" value="show" onclick="new MyType().show();" />
</body>
</html>

there is a copy http://jsfiddle.net/mqBtA/3/

Attachments (0)
Change History (1)

Changed September 10, 2013 07:54PM UTC by dmethvin comment:1

resolution: → notabug
status: newclosed

As documented: http://api.jquery.com/trigger/

Note: For both plain objects and DOM objects other than window, if a triggered event name matches the name of a property on the object, jQuery will attempt to invoke the property as a method if no event handler calls event.preventDefault(). If this behavior is not desired, use .triggerHandler() instead.