3gwebtrain
3gwebtrain

Reputation: 15293

Bootsrap - how to set the title and content dynamically

I would like to show a bootstrap modal for my app. In which I would like to pass the size, title and content parameters. so using a single modal i can use multiple requirement.

with all above information i would like to pass the default options too.

at present i do like this:

var options = {
    "backdrop" : "static",
    "keyboard" : false,
    "show" : false
}

$('#basicModal').modal(options);

How can i extend this in to my requirement using the bootstrap inbuild/custom functions?

Any one help me please?

Live Demo

Update

I find a way to pass params, how it works?

http://www.jqueryscript.net/demo/jQuery-Modal-Dialog-Plugin-For-Bootstrap-3-Bootstrap-3-Dialog/examples/#available-options

Upvotes: 0

Views: 64

Answers (2)

waki
waki

Reputation: 1258

http://jsfiddle.net/dwojLdjk/5/

var options = {
    "backdrop" : "static",
    "keyboard" : false,
    "show" : true
}

$('#showModal').click(function() {
    $("#resultFormModal").find("h4.modal-title").html('new title');
    $("#resultFormModal").find("div.modal-body").html('new message');
    $("#resultFormModal").modal(options);
});

Upvotes: 1

AB Vyas
AB Vyas

Reputation: 2389

You can set header like this

$('#myModalLabel').html('New Header');

and for body

$('.modal-body').html('<h1>New Body</h1>');

Below is fiddle demo.

Fiddle

Upvotes: 0

Related Questions