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

  • SEARCH
  • Home
  • 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 8088345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T19:03:51+00:00 2026-06-05T19:03:51+00:00

For a project of mine I would like to extend twitter bootstrap modal window

  • 0

For a project of mine I would like to extend twitter bootstrap modal window capabilities.

I would like my modal window to get the functionality of Java CardLayout.
For those who don’t know, the CardLayout allows a container (in our case, the modal window), to accept multiple card childeren (in our case, div’s). Each child gets an index, and container initially displays the child with index ‘0’. The CardLayout interface contains function as “previous(), next(), first(), last()” wich change the displayed card according to their index.

This is a template of the HTML that I would like to use to generate a “card modal” with 4 “Cards” :

<a class="btn" data-toggle="modal" href="#myModal" >Launch Modal</a>

<div class="modal hide" id="myModal">
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal">×</button>
        <h3>Modal header</h3>
    </div>
    <div class="modal-body">
        <div class="modal-card" card-index="0">
            This is the initial state
        </div>
        <div class="modal-card" card-index="1">
            This is the Step 1
        </div>
        <div class="modal-card" card-index="2">
            This is the Step 2
        </div>
        <div class="modal-card" card-index="3">
            This is the final State
        </div>
    </div>
    <div class="modal-footer">
        <a href="#" class="btn" card-change="previous">Previous</a>
        <a href="#" class="btn" card-change="next">Next</a>
        <a href="#" class="btn" data-dismiss="modal">Close</a>
        <a href="#" class="btn btn-primary">Save changes</a>
    </div>
</div> 

Since I am quite new to JS, I would like as an exercise to try to make it as generic and reusable as possible.
Ideal situation would be to have a card-modal.js file that I could toss in my project JS folder to be able to create one of those anytime I want.

I am hesitating between two directions :
– Extend the Modal class (using coffeescript “extends” keyword) since after all a CardModal “IS A” Modal.
– Create a separate class that would only deal with the response to give to those previous/next buttons.

Is there any difference about the initialization for those two options ? (What would the developer have to write to actually start the required objects)

I am just looking for a “How would you do it answer” from a more experienced developer. So extra points awarded for actually showing “why is this solution better than this one”.

  • 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-06-05T19:03:53+00:00Added an answer on June 5, 2026 at 7:03 pm

    JavaScript has a function-prototype based inheritance model; this is different from ‘traditional’ class based inheritance models you’d see in Python/Java/etc. It’s also, in absolute terms, harder to use and learn (IMHO). That’s why frameworks and compilers (like CoffeeScript) have their own built in class inheritance systems.

    The downside to these ad-hoc JS class inheritance systems is that they, in general, aren’t cross compatible with other JS inheritance systems. In this particular instance the Modal class, I can see from the source code, is not a CoffeeScript class. As such, I would highly recommend against trying to extend it with CoffeeScript—that way lies madness.

    I recommend you go with your option #2—build the functionality to toggle through prev/next separately. You should develop your CardLayout as standalone Javascript/jQuery which expects to be given a <div class="card-container"> element which contains N <div class="card" > elements such that no matter where the card-container element lives in the DOM you can create it with setupCardLayout($('.card-container')).

    Then all you have to do to integrate it with Bootstrap Modal is just listen for the event for when the modal is shown

    $('#id-of-modal').on 'shown', ()->
        setupCardLayout($(this))
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to implement some Drag-select functionality into a project of mine but
In a Java Project of mine, I would like to find out programmatically which
For a hobby project of mine involving a 3d printer I would like to
I would like to use WebAPI for an existing project of mine (classic ASP.NET),
I would like to use URNs in a project of mine. And I am
A current jQuery project of mine requires browser resize (width AND height) functionality, some
I have this datagridtemplatecolumn of mine which I would like to bind to a
I'm using FancyBox throughout the project I'm working on, and would like to implement
I recently put a django project of mine into its beta stages and would
I have been trying to get a project of mine to run but 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.