bootstrap-3-modal
bootstrap-3-modal copied to clipboard
add modal with Template.
I often find myself to add a modal view to a form. So I'm wondering if it would be in the scope of this package to add a new function along these lines :
Modal.showWithTemplate = (template,data,title) ->
Modal.show("ModalTemplate",{template: template, data: data, title: title})
Where the template would be something like this :
<template name="ModalTemplate">
<div id={{template}} class="modal fade">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
{{title}}
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">X</span> <span class="sr-only">{{_ "close"}}</span>
</button>
</div>
<div class="modal-body">
{{> Template.dynamic template=template data=data}}
</div>
</div>
</div>
</div>
</template>
This simple function would allow the reuse of a single template for many modals. If you think this could be a worthy addition, and if you don't have time to do it yourself, I'll be happy to prepare a PR .
You mean that <template name="ModalTemplate"> ... </template>
should be part of the package? That would lead to less code to write for the ones using this package, which would be great, but then the ones using this package can't customized the modal, e.g. changing the size of the modal, right?
If this package should provide a standard modal template, the default options for that modal template should be picked carefully. Any suggestions on how to pick these default options?
no, just the function. The template would be left to the user to define (once). So the function should have one more (maybe optional argument) . And maybe add the template in the readme as example ...
Modal.showWithTemplate = (template,data,title,modalTemplate) ->
unless modalTemplate then modalTemplate = "ModalTemplate"
Modal.show(ModalTemplate,{template: template, data: data, title: title})
Or something along these lines ...
Most modals on one and the same website looks and function the same, right? And Modal.showWithTemplate
would be a convenient way to achieve that? Well, if you send me a pull request with this functionality, I'll add it, but it should:
- Work with
Modal.allowMultiple = true
(you might not need to do anything special to achieve this). - Be possible to specify both data context and modal options. If the model template name can be specified globally (so one doesn't need to use if when calling
Modal.showWithTemplate
), so should the modal options.
Sounds good?