Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6904933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:07:19+00:00 2026-05-27T08:07:19+00:00

I have a modal dialog class that I am extending in order to show

  • 0

I have a modal dialog class that I am extending in order to show a form with some buttons. Here is the ModalView view:

App.ModalView = Backbone.View.extend({
    events: {
        "click .dismiss": "dismiss"
    },
    element: "<section class='modal'><div class='overlay'></div><div class='content'></div></section>",

    initialize: function () {
        this.el = $(this.element);

        this.setupElement();
        this.bindContext();
        this.extendEvents();
        this.render();
        this.miscellaneous();
    },

    bindContext: function () {
        _.bindAll(this, "dismiss", "render", "setBoxStyle");
    },

    setupElement: function () {
        this.template = $("#modal-template");
    },

    miscellaneous: function () {},
    extendEvents: function () {},

    render: function () {
        $(this.el).find(".content").html(this.template.html());
        $("body").append(this.el);

        this.setBoxStyle();

        if (this.options.content) {
            $(this.el).find(".content").html(this.options.content);
        }
    },

    getMargin: function (width, height) {
        var top, left;

        width = parseFloat(width);
        height = parseFloat(height);

        top = Math.max(0, Math.round((window.innerHeight - height) / 2));
        left = Math.max(0, Math.round((window.innerWidth - width) / 2));

        return top + "px " + left + "px";
    },

    setBoxStyle: function () {
        var css = this.options.css || {};

        var el = $(this.el).find(".content");

        el.css(css);

        var width = el.outerWidth();
        var height = el.outerHeight();
        css.margin = this.getMargin(width, height);

        el.css(css);
    },

    dismiss: function () {
        this.remove();
    }
});

Here is the extended view:

App.AddRecordView = App.ModalView.extend({
    setupElement: function () {
        this.template = $("#add-record-template");
    }
});

Here is the template:

<script type="text/template" id="add-record-template">
    <h1>Add Record</h1>

    <button class="green save">Save Record</button>
    <button class="cancel dismiss">Cancel</button>

</script>

Here is how I initialize the view:

this.addRecordView = new App.views.addRecord({
    model: this.model,
    css: {
        width: "400px"
    }
});

For some reason the dismiss event never fires when I click the button. What’s going on here?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:07:20+00:00Added an answer on May 27, 2026 at 8:07 am

    You have not defined an el or a tagName for your view. Backbone assigns the delegate events to a div by default if none of the above are declared. In your initialize function you then set the el explicitly, overriding the el with the eventhandlers attached. Try to set your section as tagName and remove it from your element property. Then append your elements to this.el.
    Sorry for not providing a code example but I am writing on my phone.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery modal dialog that displays a partial view. The partial view
I have a simple class that I want to use to show a Dialog
I have a modal dialog where I place the contents of an html form
I have a modal dialog that is created with the following: procedure TFormCompose.createParams(var Params:
I have a modal dialog plugin written in jquery, that binds to the click
We have a requirement for a modal dialog that makes the page modal except
I have a modal dialog that I would like to implement a right mouse
I have a dropdown list that I'm converting over to a custom modal dialog.
I have a modal dialog which has a form. When a user clicks the
I have modal dialog popups filled with various videos, played by JW Player. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.