GithubHelp home page GithubHelp logo

backbone.bootstrap-modal's People

Contributors

breybrey678 avatar cthielen avatar ducin avatar jcromartie avatar jmmk avatar mitchellrj avatar orloffv avatar powmedia avatar seanparmelee avatar stephanebachelier avatar tylerlh avatar wwebfor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backbone.bootstrap-modal's Issues

How do I NOT display the Ok button?

I've tried with this inside the view passed on to the modal and it looks like the button has not loaded yet when render gets called. Howerver the same works when an event (like click) is fired from the modal for example -> that proves the button is accessible.

render: function() {
      $(this.el).html(template);
      $('.ok').hide();
      return this;
    },

Improve readme

It should probably pointed out in the readme that you cannot bind on the shown and hidden event directly on the modal but one must use modal.$el instead:

Does not work

modal.on('shown', function() {
  // some code
});

Works

modal.$el.on('shown', function() {
  // some code
});

shown event not working

I hope this is user error, but I am unable to get the shown event working. I have tried several combinations.

modal = new Backbone.BootstrapModal({ content: view, title: title, animate: true }).open();

                        modal.bind("shown", function(){
                            alert("hello");
                        });

Is this a possible conflict with bootstrap?

[Feature Request] Enter to submit

When enter is pressed I think "ok" is a resonable default.

I added the following to the events:

  'keypress': function(event) {
     if (event.which == 13) {
       event.preventDefault();
       this.trigger('ok');
         if (this.options.content && this.options.content.trigger) {
           this.options.content.trigger('ok', this);
         }

         if (this.options.okCloses) {
           this.close();
         }
       }
    }

The above does only seem to work with forms/inputs though...
Perhaps it's something you'd want to add to the offical version?

/Stefan

Adjusting width of the modal dialog

I suggest adding an option that will append a class to the modal-dialog div. This allows us to set custom width or styling if necessary to override the default behavior.

License

What's the license for the code?

Swap out modal views dynamically

This works great and saved us a ton of time. Is there a way to replace the existing view inside the modal with another one dynamically? I have a backend process that takes a while to publish the content and would like to show a spinner gif in the modal while the content is being fetched. Once the content is available, I would like to swap out the spinner view with the actual content. I couldn't find a way to set the content at run time though.

Closing bootstrap alerts inside a modal closes the modal.

The close event on the modal listens for a click on the close class ('.close'). The problem is that Bootstrap uses this class for several elements in addition to the modal (e.g. dismissible alerts). Therefore if someone, for example, has an alert within a modal, two close classes will be present and the modal will be closed when the close button on the alert is clicked.

This can be easily fixed by eliminating the ambiguity of which close class belongs to the modal. One solution would be to add another class to the modal close button, such as 'modal-close'. We could then change the trigger event to be on '.modal-close' instead of just '.close'.

Allow the option to focus a text input

Currently there is only an option to focus on buttonOk. It would be nice to have the option to focus an arbitrary field by class.

view = new Backbone.BootstrapModal({ content: $('.formclass').html(), focus: 'field_class' }).open();

Make content views aware of modals

First off, thanks for this project. I had a rather hackish way of doing bootstrap modals with my backbone-forms but this is much more elegant.

In my case it would be useful to make the views aware of their modal My views have functions that save/validate them and it makes more sense to me to have things like:

modal.on('ok', () function{
if (! @noteFormView.submit()) {
modal.preventClose();
}
}

in the model instead of outside. This is particularly obvious when using a bunch of views that inherit from the same base class (and the bass class manages the saving). It would be much more DRY - to me - to handle the 'ok' click in the base model rather than outside of the views all together.

Impossible to disable Esc key functionality

Right now it's not possible to disable the use of the Esc key to close the modal.

Both "options.escape" and "options.modalOptions.keyboard" are ignored.
In fact, the code shows that "options.escape" it not used at all throughout the code.

'hidden' event is not caught

in my environment, MacOX, Chrome, following potion of code of 'backone-bootstrap-modal.js' is not working as expected, the code handling 'hidden' event is not executed

close: function() {
            var self = this,
                $el = this.$el;

            //Check if the modal should stay open
            if (this._preventClose) {
                this._preventClose = false;
                return;
            }
            $el.modal('hide');

            $el.one('hidden', function() {
                self.remove();

                self.trigger('hidden');
            });

the reason is that the event bind is called after "modal('hide')" or to say the event bind is execute after the event had happened, i temporally worked around it by switch the order like following

           $el.one('hidden', function() {
                self.remove();

                self.trigger('hidden');
            });

            $el.modal('hide'); 

i dont know if orignal code works on other environment , i think it would be good to bind the event at the initialization, like in the open or render method

Negative z-index issue with multiple modals (and possible solution)

Thanks for the great module, Charles!

Preamble
I'm trying to implement dialogs as a way to interact with forms, display alerts, progress and confirmation messages.

So, in my case, a form submission sequence would look like this:

  1. User opens modal with a form.
  2. User submits the form.
  3. Modal with form closes.
  4. Progress modal being displayed (new alert modal)
  5. On submission confirmation progress modal is closed.
  6. Confirmation modal being displayed (new alert modal)

While it seems like too many steps and modals, it works quite well and unobtrusive, IMHO.

The issue

When I submit the form many times in a row to get a few cycles of the sequence, at some point I end up with a modal that has negative z-index. I stepped through your code with a debugger to see what was going on, but couldn't really pin-point where the negative count was starting. Its like close() method was ran multiple times on the same modal, but I couldn't see it. One thing I noticed, is that Modal.count++ happens after an on.cancel event setter on line 222. So, I moved Modal.count++ higher in the code right below modal creation $el.modal(..) on line 171 and it fixed my problem.

I'd appreciate if you could look into this whenever you have a chance.

Thanks again!

How to NOT display the Cancel and OK buttons?

I love this little library! It got me start using modals with Backbone quick and easy. I want to use it so that users can do a search in my DB, click one of the results, and return that result to the main screen to edit it.

I already have a little cross to close the modal on the right top (<button type="button" class="close" data-dismiss="modal" aria-hidden="true">X</button>), and because of this, I don't need the Cancel and OK button.

Does anybody know how I can somehow prevent it from displaying the cancel and ok button? All tips are welcome!

Any advice on using with r.js optimizer?

Hi, thanks for this tool it's a great help in integrating backbone and bootstrap. I've used this in a couple of spot's and I'm attempting to ready my app for deployment. To do this I'm using the r.js optimizer (part of require). I've used a shim set up to pully the libraries my app uses together and as part of that I point the optimizer to my shim file as my mainConfigFile option and I set the wrapShim flag to tru so that backbone's dependancies get loaded.
However this then results in backbone.bootstrap-modal declaring that '_' is undefined as the scop has been changed by the wrap.
Is there a suggested way of resolving this so I can use this library in an optimized environment?

Events in the view

The example in the readme about events in the view doesn't seem to work, as the alert never shows:

var view = new Backbone.View({
    initialize: function () {
        this.bind("ok", okClicked);
    },

    okClicked: function (modal) {
        alert("Ok was clicked");
        modal.preventClose();
    }
});

var modal = new Backbone.BootstrapModal({ content: view }).open();

This is the related code in backbone.bootstrap-modal.js:

'click .ok': function(event) {
  event.preventDefault();
  this.trigger('ok');

  if (this.options.content && this.options.content.trigger) {
    console.log("Content:", this.options.content);
    console.log("Modal  :", this);
    this.options.content.trigger('ok', this);
  }

  if (this.options.okCloses) {
    this.close();
  }
}

I'm rather new to Backbone so I don't fully get what's happening with the context when this.options.content.trigger('ok', this) is called.

If someone could explain this to me and nudge me in the right direction to get the above example working, that would be great!

Thanks!

Visual bugs when displaying 2 modals

When a second modal is created over another, the background does not cover the first modal.

The top of the second modal is also set to the top of the first modal, no matter what the height.

pass model when using a custom template?

can you get to model attributes when using a custom template?

i keep getting errors like this when trying:

Uncaught ReferenceError: lastName is not defined
(anonymous function)
c underscore-min.js:30
Backbone.View.extend.render backbone.bootstrap-modal.js:126
Backbone.View.extend.open backbone.bootstrap-modal.js:149
Backbone.View.extend.searchResultAction app.js:263
f.event.dispatch jquery-1.7.2.min.js:3
h.handle.i jquery-1.7.2.min.js:3

is there anything obviously wrong with the below code?

var tmpl = _.template($("#employee-details-template").html());
var mdl = new Backbone.Model({ firstName: 'cooooooole', lastName: 'oooooorton' });
var view = new Backbone.View({ model : mdl });
var modal = new Backbone.BootstrapModal({ content: view, template: tmpl , animate: true }).open();

thanks in advance, cole

Multiple modals with different width

Your plugin has proved to be great help. Thanks.

Can I know, if I have three modals with different width how can I handle it? Is there anything which is configurable?

Its not an issue, actually. I may be hitting wrong place, please let me know if this is true.
Regards,

on Hide/Hidden event missing when clicked outside the modal

When allowCancel === true - modal can be closed by clicking outside of its boundaries. The View as far as I can tell doesn't react to this event via hidden.

After testing: cancel, close, ok and click outside - I determined that all actions trigger hidden.bs.modal. First 3 events also trigger hidden in the BootstrapModal, but not the click outside of the modal.

I had to implement a workaround and instead of using this.bind('hidden', callback), I'm using:

$(document).on('hidden.bs.modal', '.modal', {view: this}, callback);

It would be nice if hidden event would cover the click outside of modal boundaries as well.

Version?

Great extension. Could you add version number so we can track the changes in our list of dependencies?

Please publish 0.9.1 with Bootstrap 3 support into Bower

$ bower info backbone.bootstrap-modal
bower backbone.bootstrap-modal#*       not-cached git://github.com/powmedia/backbone.bootstrap-modal.git#*
bower backbone.bootstrap-modal#*          resolve git://github.com/powmedia/backbone.bootstrap-modal.git#*
bower backbone.bootstrap-modal#*         download https://github.com/powmedia/backbone.bootstrap-modal/archive/v0.9.0.tar.gz
bower backbone.bootstrap-modal#*          extract archive.tar.gz
bower backbone.bootstrap-modal#*         resolved git://github.com/powmedia/backbone.bootstrap-modal.git#0.9.0

{
  name: 'backbone.bootstrap-modal',
  homepage: 'https://github.com/powmedia/backbone.bootstrap-modal',
  version: '0.9.0'
}

Available versions:
  - 0.9.0

Version 0.9.1 with support for Bootstrap 3 modal markup is not yet available on Bower.

return data

Great job with this plugin, worked out of the box but now I'm having trouble figuring out how to get data from the content on Ok click, for example lets say I have an input field and write something in it, how do I get that data out when I click ok?

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.