1

I have a click handler that is firing twice even though it is only defined in 1 file. When debugging, and looking at the click handlers on that element, I see there are 2 script files that have registered the click event, the normal file and a mysterious VM - "myfile" that I did not make. How do I stop it hitting the unwanted VM script?

enter image description here

edit:

html is simply: <a href="#" id="clear-matches">Clear matches</a>

function:

 $('#clear-matches').click(function (e) {
        e.preventDefault();
        bootbox.dialog({
            message: "Are you sure?  This will delete all your matches from all divisions for the latest season!!",
            buttons: {
                btn1: {
                    "label": "Cancel",
                    "className": "btn-default"
                },
                btn2: {
                    "label": "Delete",
                    "className": "btn-danger",
                    "callback": function () {
                        var data = { leagueId: leagueId }
                        $.post(window.rootUrl +  "League-ClearMatches",
                            data,
                            function (result) {
                                bootbox.alert(result);
                            });
                    }
                }
            }
        });
    });
BMills
  • 881
  • 1
  • 10
  • 24
  • 3
    Please share your code. – BenM Jun 15 '18 at 13:58
  • By the way, `VMxyz` identifiers are generated by Dev Tools for dynamically injected scripts that have no associated URL. – BenM Jun 15 '18 at 13:59
  • See [Chrome Development Tool: \[VM\] file from javascript](https://stackoverflow.com/a/17373477/128165) – Gabriele Petrioli Jun 15 '18 at 14:01
  • " is firing twice even though it is only defined in 1 file"...an event can be defined once, and fired a million times, depending on what occurs during the life of the page. That comment doesn't make much sense, unless really you mean that the same event handler gets attached to an element twice? That would be a problem for us to fix, if you didn't want that to happen. But without seeing any code or other info we really have no way to know how or why anything is happening in your application. We can't fix pictures of your dev tools. – ADyson Jun 15 '18 at 14:06
  • have added the click function from sharedFunctions.js – BMills Jun 15 '18 at 15:27

1 Answers1

0

In my case, I have changed "$(document)" to "$('#id_name')" and after making this change VM file stopped being created.