Chris
Chris

Reputation: 3129

Added click event to span tag and its getting called twice from namespace

I do have a span tag that I added a click event to and it gets called twice even though I only click it once and I have no idea why. If I run this code in a separate project then the button only gets called once, but when I bring it into a working project then click events are happening twice.

I am using a namespace for my code

and here is the code

the HTML

<span type="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Save" class="" id="btnSaveWindow"><i class="fa fa-plus"></i></span>
<span type="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Remove Item" class="" id="btnRemoveFromItemsGrid"><i class="fa fa-trash"></i></span>
<span type="" data-toggle="tooltip" data-placement="top" title="" data-original-title="Close" class="" id="btnClosePromptDialog"><i class="fa fa-remove"></i></span>

And here is the javascript

var ItemsGrid = ItemsGrid || {};
ItemsGrid.Prompts = ItemsGrid.Prompts || {};

ItemsGrid.Prompts = {
    AddButtonEventsForPrompts: function () {
        $('#btnRemoveFromItemsGrid').on('click', () => { 
            this.DeleteItemOrAttachment("2");
        });

        $('#btnClosePromptDialog').on('click', () => {
            this.ClosePrompt();
        });
    },
    ClosePrompt: function () 
        $('#SiteOverlayFullScreen').css('display', 'none');
        $('#PromptsDialog').css('display', 'none');
    },
    DeleteItemOrAttachment: function (deleteItemKey) {
        this.DeleteItemOrAttachment_Success(deleteItemKey);
    },
    DeleteItemOrAttachment_Success: function (deleteItemKey) {       
        this.DeleteItemOrAttachment_Success(deleteItemKey);
    }
}

Upvotes: 0

Views: 142

Answers (0)

Related Questions