When I open the bootbox, enter information, then press enter, it's closing the bootbox and scrolling back to the top of the page. (It's not pressing the create button or the cancel button). I've tried changing classname to btn-primary. This doesn't help.
Here's the code:
bootbox.dialog({
title: 'Create a new bucket',
message:
'<div class="row"> ' +
'<div class="col-md-12"> ' +
'<form class="form-horizontal"> ' +
'<div class="form-group"> ' +
'<label class="col-md-4 control-label" for="bucketName">Bucket Name</label> ' +
'<div class="col-md-8"> ' +
'<input id="bucketName" name="bucketName" type="text" placeholder="Enter bucket name" class="form-control" autofocus> ' +
'<div>' +
'<span id="bucketModalErrorMessage" ></span>' +
'</div>'+
'</div>' +
'</div>' +
'<div class="form-group"> ' +
'<label class="col-md-4 control-label" for="bucketLocation">Bucket Location</label> ' +
'<div class="col-md-8"> ' +
'<select id="bucketLocation" name="bucketLocation" class="form-control"> ' +
generateBucketOptions(self.settings.bucketLocations) +
'</select>' +
'</div>' +
'</div>' +
'</form>' +
'</div>' +
'</div>',
buttons: {
cancel: {
label: 'Cancel',
className: 'btn-default'
},
confirm: {
label: 'Create',
className: 'btn-success',
callback: function () {
var bucketName = $('#bucketName').val();
var bucketLocation = $('#bucketLocation').val();
if (!bucketName) {
var errorMessage = $('#bucketModalErrorMessage');
errorMessage.text('Bucket name cannot be empty');
errorMessage[0].classList.add('text-danger');
return false;
} else if (!isValidBucketName(bucketName, false)) {
bootbox.confirm({
title: 'Invalid bucket name',
message: 'Amazon S3 buckets can contain lowercase letters, numbers, and hyphens separated by' +
' periods. Please try another name.',
callback: function (result) {
if (result) {
self.openCreateBucket();
}
},
buttons: {
confirm: {
label: 'Try again'
}
}
});
} else {
self.createBucket(bucketName, bucketLocation); //THIS IS IMPORTANT
}
}
}
}
});