This is a migrated thread and some comments may be shown as answers.

Bootstrap modals and Kendo UI divs

1 Answer 350 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Ben asked on 06 Mar 2013, 05:21 PM

I have a Bootstrap modal setup as below, with DIVs that are supposed to be linked to the Kendo UI divs.

However, upon clicking the submit button, the form is not hidden (visible: hideMain) and the message is not presented (visible: confirmed).  Despite the divs and JS being setup correctly. 

What should happen is that when "send message" is clicked, the form div should hide and the message div should appear.

   <!-- Button to trigger modal -->
    <a href="#emailModal" role="button" class="btn btn-primary" data-toggle="modal">Email Us</a>
    <!-- Modal -->
    <div id="emailModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="emailModalLabel" aria-hidden="true">
    <div class="modal-header">
    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
    <h3 id="emailModalLabel">Email Us</h3>
    <div class="modal-body">
<!-- Email Form -->
<div data-bind="visible: hideMain">
<p><label>Title</label><br />
<select data-bind="source: titles, value: title"></select><br />
<label>First Name</label><br />
<input type="text" data-bind="value: firstName" /><br />
<label>Last Name</label><br />
<input type="text" data-bind="value: lastName" /><br />
<label>Company Name </label><br />
<input type="text" data-bind="value: companyName" /><br />
<label>Email Address</label><br />
<input type="text" data-bind="value: emailAddress" /><br />
<label> Phone Number</label><br />
<input type="text" data-bind="value: phone" /><br />
<label>Subject Name</label><br />
<select data-bind="source: subjects, value: subject"></select><br />
<label>Message Body</label><br />
<textarea data-bind="value: message" cols="100" rows="10"></textarea></p>
<p><label class="checkbox"><br />
<input type="checkbox" data-bind="checked: agreed"> I agree to your terms & conditions and privacy policy<br />
<div class="form-actions">
<p><button data-bind="enabled: agreed, click: register" class="btn btn-primary">Send message</button></p>
<!-- End Email Form -->
<!-- Confirm Message -->
<div data-bind="visible: confirmed">
<p><span data-bind="text: message"></span></p>
<!-- End confirm Message -->
    <div class="modal-footer">
    <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
    <!-- <button class="btn btn-primary" data-bind="enabled: agreed, click: register">Save changes</button> -->
<!-- end modal -->

$(document).ready(function() {
//jQuery(document).ready(function($) {
var viewModel = kendo.observable({
firstName: "",
lastName: "",
companyName: "",
subject:"Sales Request",
subjects:["Sales Request","Literature Request","Recruitment Question","Comment","Other Request"],
agreed: false,
confirmed: false,
register: function(e) {
var that = this;
function(data) {
that.set("messageID", data.message);
this.set("confirmed", true);
startOver: function() {
this.set("confirmed", false);
this.set("agreed", false);
this.set("hideMain", true);
this.set("firstName", "");
this.set("lastName", "");
this.set("companyName", "");
this.set("emailAddress", "");
this.set("phone", "");
this.set("subject", "Sales Request");
this.set("message", "");
this.set("messageID", "");
kendo.bind($("form"), viewModel);

1 Answer, 1 is accepted

Sort by
Telerik team
answered on 08 Mar 2013, 10:11 AM
Hello Ben,

Does the scenario work if the form is not inside a modal popup? If yes, then the problem is caused by the fact that the form is moved in the DOM. In this case you need to first create the modal popup and then create the Kendo UI MVVM bindings.

All the best,
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question