I am submitting a form using Ajax and then notify the user.
I have three different pop-up modals for wait, success and error respectively.
When the submit button is clicked, the wait modal pops while the form gets submitted. Thereafter either the success or error modal pops up. Issue is that on HTTP error the wait modal fails to close and as a result overlays the error modal. How can I solve this?
<!-- Success Modal-->
<div class="modal fade" id="notify" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="ModalTitle">Success</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
#{
string action = ViewContext.RouteData.Values["action"].ToString().ToLower();
if (action == "Create")
{
action = "created";
}
else
{
action = "updated";
}
}
Record has been successfully #action.
</div>
<div class="modal-footer">
<button type="button" class="Close" data-dismiss="modal" onclick="closeModals()">Close</button>
</div>
</div>
</div>
</div>
<!-- Error Modal-->
<div class="modal fade" id="error" tabindex="-1" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header" id="error-header">
<h5 class="modal-title" id="ModalTitle">Error</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
Failed to #ViewContext.RouteData.Values["action"].ToString().ToLower() record.
</div>
<div class="modal-footer">
<button type="button" id="modalClose" data-dismiss="modal" class="CloseError" onclick="closeModals()">Close</button>
</div>
</div>
</div>
</div>
<!--Please Wait Modal-->
<div class="modal fade" id="wait" role="dialog" aria-labelledby="ModalCenterTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-centered" role="document" style="background-color: transparent; text-align: center; border-style: none;">
<div class="modal-content" style="background-color: transparent; text-align: center;border-style:none;">
<div class="modal-body" style="background-color: transparent; text-align: center;border-style:none;">
<img id="waitImage" src="~/images/orderit_logo.png" height="100" width="100" />
<div style="color: #f9a51a;">
please wait...
</div>
</div>
</div>
</div>
</div>
<script>
$("#Save").on("click", function (event) {
$('#wait').modal('toggle');
var formData = new FormData(document.getElementById("form"));
$.ajax({
url: window.location.pathname,
type: 'POST',
data: formData,
success: function (data) {
$('#wait').modal('hide');
$('#notify').modal('toggle');
},
error: function (data) {
$('#wait').modal('hide');
$('#error').modal('toggle');
},
failure: function (data) {
$('#wait').modal('hide');
$('#error').modal('toggle');
},
cache: false,
contentType: false,
processData: false
});
return false;
})
});
</script>
I resolved this by using a normal div that fills entire page and set its opacity to 80%.
<div id="wait">
<img id="waitImage" src="~/images/orderit_logo.png" height="100" />
<div style="color: #f9a51a; top: 65%; position: absolute; text-align:center;width:100%;">
please wait...
</div>
</div>
#wait {
position: absolute;
top: 0px;
bottom: 0px;
width: 100%;
background-color: rgba(19, 33, 106, 0.8); /*#f9a51a*/
text-align: center;
border-style: none;
z-index: 3000;
display:none;
}
then call:
document.getElementById('wait').style.display = 'block';
or
document.getElementById('wait').style.display = 'none';
Related
I'm trying to create a page that when you click on the create product button
a modal pops up and then you enter whatever you like.
I'm using summernote as my WYSIWYG editor and I'm also using vue as my frontend.
The problem I'm having is that my description isn't being saved.
In my layouts.app I have summernote's cdn.
Here is my code
My Create.vue
<template>
<transition name="modal-fade">
<div>
<div class="modal-backdrop show"></div>
<div class="modal" style="display: inline;">
<div class="modal-dialog modal-dialog-scrollable" role="document" style="width: 680px; max-width: 680px;">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Create Product</h5>
<button type="button" class="close" #click="close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div>
<label>Name</label>
<input type="text" class="form-control" v-model="name">
</div>
<div class="mt-2">
<label>Description</label>
<textarea id="summernote" v-model="description"></textarea>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" #click="close">Close</button>
<button type="button" class="btn btn-success" #click="save">Save</button>
</div>
</div>
</div>
</div>
</div>
</transition>
</template>
<script>
export default {
props: [],
data() {
return {
name: null,
description: null,
}
},
methods: {
close() {
this.$emit('close');
},
save() {
var description = document.getElementById("summernote").value;
axios.post('/admin/products', {
name: this.name,
description: description,
}).then((response) => {
});
}
},
mounted(){
$('#summernote').summernote();
}
}
</script>
<style>
.modal-fade-enter,
.modal-fade-leave-active {
opacity: 0;
}
.modal-fade-enter-active,
.modal-fade-leave-active {
transition: opacity .25s ease
This is my Modal link
<div class="blog-content">
<button type="button" class="btn btn-flat red-text p-1 my-1 mr-0 mml-1 collapsed" data-blog_id="{{$item->id}}" data-blog_title="{{$item->title}}" data-blog_content="{{$item->content}}" data-blog_image="{{$item->image}}" data-toggle="modal" data-target="#exampleModalScrollable">Read More</button>
</div>
This Is my Modal
<div class="modal fade" id="exampleModalScrollable" tabindex="-1" role="dialog" aria-labelledby="exampleModalScrollableTitle" aria-hidden="true">
<div class="modal-dialog modal-dialog-scrollable" role="document">
<div class="modal-content">
<div class="modal-header"> </div>
<div class="modal-body">
<h5 class="modal-title py-3 text-center" id="title" name="title" style="font-family: 'Bitter', serif;"></h5>
<img class="card-img-top rounded-0 pb-2" name="image" src="" alt="no image">
<p class="text-justify" id="content" name="content" style="font-family: 'Poppins', sans-serif;">
</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
This my My Bootstrap modal js from where i trying to set the address of image "src".
is this the correct way of sending the "src" because i have stored the photo in this directory " public/storage/blog/images/"
$('#exampleModalScrollable').on('show.bs.modal',function(event){
var button= $(event.relatedTarget)
var title= button.data('blog_title')
var content=button.data('blog_content')
var image=button.data('blog_image')
var blog_id=button.data('blog_id')
var modal= $(this)
//modal.find('.modal-title').text('Edit Blog');
modal.find('.modal-body #title').text(title);
modal.find('.modal-body #content').text(content);
modal.find('.modal-body #data-image').attr("src", "{{asset('public/storage/blog/images/"+ $(this).data(image) + "')}}");
modal.find('.modal-body #blog_id').val(blog_id);
})
I'd pass the img url as data attribute:
<div class="blog-content">
<button data-img-src="{{ asset('/storage/blog/images/' . $this->image) }}"></button>
</div>
And in javascript, access it with $(this).data('img-src')
modal.find('.modal-body #data-image').attr("src", $(this).data('img-src'))
I am trying to get a modal to show upon redirect to a page.
I am following this response (Laravel how to redirect back to boostrap modal dialog window)
My controller:
return redirect('postings')->with('welcome_msg');
My view:
#if(Session::has('welcome_msg'))
<script>
$(function() {
$('#myModal').modal('show');
});
</script>
#endif
<div class="modal fade" id="myModal role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
However, the modal is not showing upon pop-up. What am I doing wrong?
<div class="modal fade" id="myModal role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
#if(Session::has('welcome_msg'))
<script>
$(function() {
$('#myModal').modal('show');
});
</script>
#endif
This may fix it. HTML has to load before javascript.
try this in your blade just before closing tag of </ body>
#if (session()->has('welcome_msg'))
<script>
$('#YourModalName').modal('toggle');
</script>
#endif
As you can see here, I have a button that launches a modal. Setting an href url for the button this url is automatically loaded into modal by Bootstrap 3.
The fact is this page is loaded into modal root (as said in the bootstrap 3 documentation for modals usage). I want to load it into the modal-body instead.
Is there a way to do it via attributes (not javascript)? Or what is the most automatic way to do it?
P.S. I remember in Bootstrap 2 the content was loaded in the body, not the root.
This is actually super simple with just a little bit of added javascript. The link's href is used as the ajax content source. Note that for Bootstrap 3.* we set data-remote="false" to disable the deprecated Bootstrap load function.
JavaScript:
// Fill modal with content from link href
$("#myModal").on("show.bs.modal", function(e) {
var link = $(e.relatedTarget);
$(this).find(".modal-body").load(link.attr("href"));
});
Html (based on the official example):
<!-- Link trigger modal -->
<a href="remoteContent.html" data-remote="false" data-toggle="modal" data-target="#myModal" class="btn btn-default">
Launch Modal
</a>
<!-- Default bootstrap modal example -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
Try it yourself: https://jsfiddle.net/ednon5d1/
Check this SO answer out.
It looks like the only way is to provide the whole modal structure with your ajax response.
As you can check from the bootstrap source code, the load function is binded to the root element.
In case you can't modify the ajax response, a simple workaround could be an explicit call of the $(..).modal(..) plugin on your body element, even though it will probably break the show/hide functions of the root element.
I guess you're searching for this custom function. It takes a data-toggle attribute and creates dynamically the necessary div to place the remote content. Just place the data-toggle="ajaxModal" on any link you want to load via AJAX.
The JS part:
$('[data-toggle="ajaxModal"]').on('click',
function(e) {
$('#ajaxModal').remove();
e.preventDefault();
var $this = $(this)
, $remote = $this.data('remote') || $this.attr('href')
, $modal = $('<div class="modal" id="ajaxModal"><div class="modal-body"></div></div>');
$('body').append($modal);
$modal.modal({backdrop: 'static', keyboard: false});
$modal.load($remote);
}
);
Finally, in the remote content, you need to put the entire structure to work.
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"></h4>
</div>
<div class="modal-body">
</div>
<div class="modal-footer">
Close
Button
Another button...
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
In the case where you need to update the same modal with content from different Ajax / API calls here's a working solution.
$('.btn-action').click(function(){
var url = $(this).data("url");
$.ajax({
url: url,
dataType: 'json',
success: function(res) {
// get the ajax response data
var data = res.body;
// update modal content here
// you may want to format data or
// update other modal elements here too
$('.modal-body').text(data);
// show modal
$('#myModal').modal('show');
},
error:function(request, status, error) {
console.log("ajax call went wrong:" + request.responseText);
}
});
});
Bootstrap 3 Demo
Bootstrap 4 Demo
A simple way to use modals is with eModal!
Ex from github:
Link to eModal.js <script src="//rawgit.com/saribe/eModal/master/dist/eModal.min.js"></script>
use eModal to display a modal for alert, ajax, prompt or confirm
// Display an alert modal with default title (Attention)
eModal.ajax('your/url.html');
$(document).ready(function () {/* activate scroll spy menu */
var iconPrefix = '.glyphicon-';
$(iconPrefix + 'cloud').click(ajaxDemo);
$(iconPrefix + 'comment').click(alertDemo);
$(iconPrefix + 'ok').click(confirmDemo);
$(iconPrefix + 'pencil').click(promptDemo);
$(iconPrefix + 'screenshot').click(iframeDemo);
///////////////////* Implementation *///////////////////
// Demos
function ajaxDemo() {
var title = 'Ajax modal';
var params = {
buttons: [
{ text: 'Close', close: true, style: 'danger' },
{ text: 'New content', close: false, style: 'success', click: ajaxDemo }
],
size: eModal.size.lg,
title: title,
url: 'http://maispc.com/app/proxy.php?url=http://loripsum.net/api/' + Math.floor((Math.random() * 7) + 1) + '/short/ul/bq/prude/code/decorete'
};
return eModal
.ajax(params)
.then(function () { alert('Ajax Request complete!!!!', title) });
}
function alertDemo() {
var title = 'Alert modal';
return eModal
.alert('You welcome! Want clean code ?', title)
.then(function () { alert('Alert modal is visible.', title); });
}
function confirmDemo() {
var title = 'Confirm modal callback feedback';
return eModal
.confirm('It is simple enough?', 'Confirm modal')
.then(function (/* DOM */) { alert('Thank you for your OK pressed!', title); })
.fail(function (/*null*/) { alert('Thank you for your Cancel pressed!', title) });
}
function iframeDemo() {
var title = 'Insiders';
return eModal
.iframe('https://www.youtube.com/embed/VTkvN51OPfI', title)
.then(function () { alert('iFrame loaded!!!!', title) });
}
function promptDemo() {
var title = 'Prompt modal callback feedback';
return eModal
.prompt({ size: eModal.size.sm, message: 'What\'s your name?', title: title })
.then(function (input) { alert({ message: 'Hi ' + input + '!', title: title, imgURI: 'https://avatars0.githubusercontent.com/u/4276775?v=3&s=89' }) })
.fail(function (/**/) { alert('Why don\'t you tell me your name?', title); });
}
//#endregion
});
.fa{
cursor:pointer;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://rawgit.com/saribe/eModal/master/dist/eModal.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootswatch/3.3.5/united/bootstrap.min.css" rel="stylesheet" >
<link href="http//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<div class="row" itemprop="about">
<div class="col-sm-1 text-center"></div>
<div class="col-sm-2 text-center">
<div class="row">
<div class="col-sm-10 text-center">
<h3>Ajax</h3>
<p>You must get the message from a remote server? No problem!</p>
<i class="glyphicon glyphicon-cloud fa-5x pointer" title="Try me!"></i>
</div>
</div>
</div>
<div class="col-sm-2 text-center">
<div class="row">
<div class="col-sm-10 text-center">
<h3>Alert</h3>
<p>Traditional alert box. Using only text or a lot of magic!?</p>
<i class="glyphicon glyphicon-comment fa-5x pointer" title="Try me!"></i>
</div>
</div>
</div>
<div class="col-sm-2 text-center">
<div class="row">
<div class="col-sm-10 text-center">
<h3>Confirm</h3>
<p>Get an okay from user, has never been so simple and clean!</p>
<i class="glyphicon glyphicon-ok fa-5x pointer" title="Try me!"></i>
</div>
</div>
</div>
<div class="col-sm-2 text-center">
<div class="row">
<div class="col-sm-10 text-center">
<h3>Prompt</h3>
<p>Do you have a question for the user? We take care of it...</p>
<i class="glyphicon glyphicon-pencil fa-5x pointer" title="Try me!"></i>
</div>
</div>
</div>
<div class="col-sm-2 text-center">
<div class="row">
<div class="col-sm-10 text-center">
<h3>iFrame</h3>
<p>IFrames are hard to deal with it? We don't think so!</p>
<i class="glyphicon glyphicon-screenshot fa-5x pointer" title="Try me!"></i>
</div>
</div>
</div>
<div class="col-sm-1 text-center"></div>
</div>
create an empty modal box on the current page and below is the ajax call you can see how to fetch the content in result from another html page.
$.ajax({url: "registration.html", success: function(result){
//alert("success"+result);
$("#contentBody").html(result);
$("#myModal").modal('show');
}});
once the call is done you will get the content of the page by the result to then you can insert the code in you modal's content id using.
You can call controller and get the page content and you can show that in your modal.
below is the example of Bootstrap 3 modal in that we are loading content from registration.html page...
index.html
------------------------------------------------
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script type="text/javascript">
function loadme(){
//alert("loadig");
$.ajax({url: "registration.html", success: function(result){
//alert("success"+result);
$("#contentBody").html(result);
$("#myModal").modal('show');
}});
}
</script>
</head>
<body>
<!-- Trigger the modal with a button -->
<button type="button" class="btn btn-info btn-lg" onclick="loadme()">Load me</button>
<!-- Modal -->
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content" >
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body" id="contentBody">
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</body>
</html>
registration.html
--------------------
<!DOCTYPE html>
<html>
<style>
body {font-family: Arial, Helvetica, sans-serif;}
form {
border: 3px solid #f1f1f1;
font-family: Arial;
}
.container {
padding: 20px;
background-color: #f1f1f1;
width: 560px;
}
input[type=text], input[type=submit] {
width: 100%;
padding: 12px;
margin: 8px 0;
display: inline-block;
border: 1px solid #ccc;
box-sizing: border-box;
}
input[type=checkbox] {
margin-top: 16px;
}
input[type=submit] {
background-color: #4CAF50;
color: white;
border: none;
}
input[type=submit]:hover {
opacity: 0.8;
}
</style>
<body>
<h2>CSS Newsletter</h2>
<form action="/action_page.php">
<div class="container">
<h2>Subscribe to our Newsletter</h2>
<p>Lorem ipsum text about why you should subscribe to our newsletter blabla. Lorem ipsum text about why you should subscribe to our newsletter blabla.</p>
</div>
<div class="container" style="background-color:white">
<input type="text" placeholder="Name" name="name" required>
<input type="text" placeholder="Email address" name="mail" required>
<label>
<input type="checkbox" checked="checked" name="subscribe"> Daily Newsletter
</label>
</div>
<div class="container">
<input type="submit" value="Subscribe">
</div>
</form>
</body>
</html>
I have to support IE8. The modal itself works fine, but my attempts to resize it (which work fine in Firefox) don't work in IE8.
I'm just adding a class (wide-modal in this example) to the modal-dialog div (the 2nd nested one in the Bootstrap structure) and applying a width via CSS, nothing fancy.
HTML:
<div class="modal fade" id="modalTest" role="dialog">
<div class="modal-dialog wide-modal">
<div class="modal-content ">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Testing Modal</h4>
</div>
<div class="modal-body">
<img src="content/Example-Infographic.jpg" width="100%" />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div>
CSS:
.wide-modal {
width: 60%;
}
I tried adding the class to the div above and below to no (positive) effect. It works like a charm where it is in Firefox, just no effect at all in IE8. I also tried with a px width, no difference. I do have the respond.js library in place so in general IE8 is behaving other than this.
In bootstrap 3 you need assign width not to .modal class but to .modal-dialog
#modalTest .modal-dialog
{
width: 500px; /* your width */
}
I used a combination of CSS and jQuery, along with hints on this page, to create a fluid width and height using Bootstrap 3. I also tested this on IE8 on Win7, and it works great.
First, some CSS to handle the width and optional scrollbar for the content area
.modal.modal-wide .modal-dialog {
width: 90%;
}
.modal-wide .modal-body {
overflow-y: auto;
}
And then some jQuery to adjust the height of the content area if needed
$(".modal-wide").on("show.bs.modal", function() {
var height = $(window).height() - 200;
$(this).find(".modal-body").css("max-height", height);
});
Full write-up and code at
http://scottpdawson.com/development/creating-a-variable-width-modal-dialog-using-bootstrap-3/
I know it is late but just found in bs3 docs you can add modal-lg class to your modals
<!-- Large modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-lg">
Large modal
</button>
<div class="modal fade bs-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
...
</div>
</div>
</div>
<!-- Small modal -->
<button class="btn btn-primary" data-toggle="modal" data-target=".bs-example-modal-sm">
Small modal
</button>
<div class="modal fade bs-example-modal-sm" tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel" aria-hidden="true">
<div class="modal-dialog modal-sm">
<div class="modal-content">
...
</div>
</div>
</div>
This will of course change the width for all of your modal windows, but it might give you a better idea on how this works. I just changed my modal windows this way.
.modal-body {
position: relative;
padding: 20px;
min-width: 800px; /* SET THE WIDTH OF THE MODAL */
}
.modal-content {
position: relative;
background-color: #fff;
border: 1px solid #999;
border: 1px solid rgba(0,0,0,0.2);
border-radius: 6px;
outline: 0;
-webkit-box-shadow: 0 3px 9px rgba(0,0,0,0.5);
box-shadow: 0 3px 9px rgba(0,0,0,0.5);
background-clip: padding-box;
width: 900px; /* SET THE WIDTH OF THE MODAL */
margin: 50px 0 0 -150px; /* CHANGE MARGINS TO ACCOMMODATE THE NEW WIDTH */
}
<!-- Button trigger modal -->
<a data-toggle="modal" href="#myModal" class="btn btn-primary btn-lg">Launch demo modal</a>
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<h4 class="modal-title">Modal title</h4>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
#modalTest.modal-dialog{
width: <insert size> !important;
}
the !important is important :v
I think you need to set the width in pixels and adjust the margin-left. For example,
.modal-dialog {
width:700px;
margin-left:-320px;
}
The margin left must be half the width of the modal, minus 30px for the scrollbar.
Here's an example on Bootply: http://bootply.com/85213