Bug Tracker

Opened 10 years ago

Closed 10 years ago

#14324 closed bug (notabug)

jquery.trigger will make a looped calling

Reported by: aiqunfang@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.2
Keywords: Cc:
Blocked by: Blocking:


there will cause a looped calling in show method.

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

        function MyType() {
            var this$ = $(this), times = 0;
            this.show = function () {
                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

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

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

Change History (1)

comment:1 Changed 10 years ago by dmethvin

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.

Note: See TracTickets for help on using tickets.