I have an event calendar where it includes CRUD. Everything works fine but I couldn't display the start and end date on the edit modal. Previously I used moment.js so I used
$('#ModalEdit #start').val(moment(event.start).format('YYYY-MM-DD HH:mm:ss'));
But due to certain reasons, now I'm using datetime-local function and I'm not sure how to display the date from the database. Or is there any other plugin that I can use to do them? Below is the code:
<script>
$(document).ready(function() {
eventRender: function(event, element) {
element.bind('dblclick', function() {
$('#ModalEdit #id').val(event.id);
$('#ModalEdit #title').val(event.title);
$('#ModalEdit #color').val(event.color);
$('#ModalEdit #start').val(event.start);
$('#ModalEdit #end').val(event.end);
$('#ModalEdit').modal('show');
});
}
});
</script>
<div class="modal fade" id="ModalEdit" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<form method="POST" action="editEventTitle.php">
<div>
<label for="title">Activity</label>
<textarea id="title" name="title></textarea>
</div>
<div>
<label for="start">Date and Time</label>
<input type="datetime-local" name="start" id="start">
</div>
<div>
<label for="end">End date</label>
<input type="datetime-local" name="end" id="end">
</div>
<div class="checkbox">
<label class="text-danger"><input type="checkbox" name="delete"> Delete event</label>
</div>
<input type="hidden" name="id" class="form-control" id="id">
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-success ">Save changes</button>
</div>
</form>
</div>
Related
I have attached my popup box code here. The close button here is not working. Im totally new to angular 6. Can anyone help me with this?
<!-- Modal Header -->
<div class="modal-header">
<h4 class="modal-title">selection</h4>
</div>
<form>
<!-- Modal body -->
<div class="modal-body">
<h5>Enter value:</h5>
<div class="form-group">
<input name="Id" type="text" class="form-control shadow-sm" placeholder="Enter value">
</div>
<div class="form-group">
<input name="name" type="text" class="form-control shadow-sm" placeholder="Enter name">
</div>
</div>
<!-- Modal footer -->
<div class="modal-footer">
<button type="button" class="btn btn-cancel shadow-sm" data-dismiss="modal">CLOSE</button>
<button type="submit" class="btn btn-submit shadow-sm">SUBMIT</button>
</div>
Try this:
import { DataModalComponent } from './patient-modal/patient-modal.component';
import { NgbModal, NgbModalOptions } from '#ng-bootstrap/ng-bootstrap';
let ngbModalOptions: NgbModalOptions = {
backdrop : 'static',
keyboard : false,
size: "lg"
};
const modalRef = this.modalService.open(DataModalComponent ,ngbModalOptions);
I need to show the values given in modal at outside the modal using AngularJS. Plunker attached here which clearly explains. Can anyone help me out........I have already checked Angular, Ui-Bootstrap site, but couldn't find the solution to the problem
HTML
<div ng-controller="ModalDemoCtrl as $ctrl" class="modal-demo">
<script type="text/ng-template" id="myModalContent.html">
<div class="modal-header">
<button type="button" class="close" aria-hidden="true" ng-click="$ctrl.cancel()">×</button><a>
<h3 class="modal-title" id="modal-title" style="color:red">Please Provide the Details Here</h3>
</a>
</div>
<form name="modalForm" novalidate>
<div class="modal-body">
<div class="form-group" ng-class="{ 'has-error': modalForm.name.$invalid }"> <!--modalForm.name.$touched &&-->
<a>*Name: </a><input name="name" ng-minlength="3"
ng-maxlength="8" ng-model="name" type="text" placeholder="Name" class="form-control" size="10" style="width: 50%" required />
</div>
<div class="form-group" ng-controller="ButtonsCtrl">
<a>*Gender: </a><pre>{{radioModel || 'null'}}</pre>
<div class="btn-group">
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Male'" uncheckable>Male</label>
<label class="btn btn-success" ng-model="radioModel" uib-btn-radio="'Female'" uncheckable>Female</label>
</div>
</div>
<div class="input-group" ng-controller="DatepickerPopupDemoCtrl">
<a>*Birth Date: Selected date is: <em>{{dt | date:'fullDate' }}</em></a><select class="form-control" ng-model="format" ng-options="f for f in formats" style="width: 50%"><option></option></select><input type="text" class="form-control" uib-datepicker-popup="{{format}}" ng-model="dt" is-open="popup1.opened" datepicker-options="dateOptions" close-text="Close" ng-required="true" alt-input-formats="altInputFormats" style="width: 50%" />
<span class="input-group-btn">
<button type="button" class="btn btn-default" ng-click="open1()"><i class="glyphicon glyphicon-calendar"></i></button>
</span>
</div>
<p ng-show="modalForm.modalPlace.$error.required">Select service</p>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-warning" type="button" ng-click="$ctrl.ok()" ng-disabled="modalForm.$invalid">OK</button>
<button class="btn btn-warning" type="button" ng-click="$ctrl.cancel()">Cancel</button>
</div>
</form>
</script>
<button type="button" class="btn btn-default" ng-click="$ctrl.open()">Open me!</button>
<div ng-show="$ctrl.selected">Name from the modal: {{ $ctrl.name }}</div>
<div ng-show="$ctrl.selected">Gender from the modal: {{ radioModel || 'null'}}</div>
<div ng-show="$ctrl.selected">DOB from the modal: {{ dt | date:'fullDate' }}</div>
What you are looking for is the modalInstance.result property, it a promise which is resolved with a value when you close your modal (or rejects when you dismiss it).
The docs already provide you with a simple example
modalInstance.result.then(function (selectedItem) {
$ctrl.selected = selectedItem;
}, function () {
$log.info('Modal dismissed at: ' + new Date());
});
Inside your modal controller you can close/dismiss the modal using these methods
var selectedItem = ...
$uibModalInstance.close(selectedItem)
// or
$uibModalInstance.dismiss(selectedItem)
With selectedItem being passes to the controller that launched the modal.
Because you code is incomplete I can't really help you much more then that, the docs hold all you need to know really.
I am working on a contact us form. After clicking on the submit button i want the form to be validated for example if text is entered in the mobile number field i want an error message to be displayed.
if all the data types in the form are correct i want a modal to be displayed which says thank you.
heres the code:
<form class="form">
<div class="line"><label style="font-size: 18px;"for="fname">First Name *: </label><input type="text" id="fname" required /></div>
<div class="line"><label for="lname">Last Name *: </label><input type="text" id="lname" required /></div>
<!-- You may want to consider adding a "confirm" password box also -->
<div class="line"><label for="email">Email *: </label><input type="email" id="email"required /></div>
<!-- Valid input types: http://www.w3schools.com/html5/html5_form_input_types.asp -->
<div class="line"><label for="tel">Mobile *: </label><input type="tel"pattern="[789][0-9]{9}" id="tel" required/></div>
<div class="line"><label for="add">Address *: </label><input type="text" id="add" required/></div>
<div class="line"><label for="ptc">Post Code *: </label><input type="number" maxlenght="6" id="ptc" required /></div>
<div><button data-target="modal1" type="submit"class=" waves-effect waves-light btn modal-trigger">Submit<i class="material-icons right">send</i></button></div>
<p>Note: Please make sure your details are correct before submitting form and that all fields marked with * are completed!.</p>
</form>
below is the javascript
$(document).ready(function(){
// the "href" attribute of .modal-trigger must specify the modal ID that wants to be triggered
$('.modal-trigger').leanModal();
});
here is the modal structure.
<div id="modal1" class="modal">
<div class="modal-content">
<h4>Thank You</h4>
<p>Our Customer service team will contact you shortly</p>
</div>
<div class="modal-footer">
OK
</div>
</div>
The problem about your code is that you are handling the wrong event. I don´t know what framework you are using but your button probably shows the modal when the button is clicked and not when the form is submitted. It would be better to watch for the submit event of the form.
(function($){
$(document).ready(function(){
$('.form').on('submit', function(e){
e.preventDefault();
$('.modal-trigger').leanModal();//Show your modal?
});
});
})(jQuery);
Here is an example I prepared using Twitter bootstrap. I used your form and a the modal of the framework. The functionality must be very similar to the one you desire.
(function($) {
$(document).ready(function() {
$('form.form').on('submit', function(e) { //Handle the submit event of the form
e.preventDefault(); //This prevents the form from submitting, You might need to delete it in your actual code
$('#myModal').modal('show'); //In bootstrap this is the function that shows the modal. It might differ on your actual code.
});
});
})(jQuery);
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<form class="form">
<div class="line">
<label style="font-size: 18px;" for="fname">First Name *:</label>
<input type="text" id="fname" required />
</div>
<div class="line">
<label for="lname">Last Name *:</label>
<input type="text" id="lname" required />
</div>
<!-- You may want to consider adding a "confirm" password box also -->
<div class="line">
<label for="email">Email *:</label>
<input type="email" id="email" required />
</div>
<!-- Valid input types: http://www.w3schools.com/html5/html5_form_input_types.asp -->
<div class="line">
<label for="tel">Mobile *:</label>
<input type="tel" pattern="[789][0-9]{9}" id="tel" required/>
</div>
<div class="line">
<label for="add">Address *:</label>
<input type="text" id="add" required/>
</div>
<div class="line">
<label for="ptc">Post Code *:</label>
<input type="number" maxlenght="6" id="ptc" required />
</div>
<div>
<button type="submit" class=" waves-effect waves-light btn modal-trigger">Submit</button>
</div>
<p>Note: Please make sure your details are correct before submitting form and that all fields marked with * are completed!.</p>
</form>
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<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">
your modal
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
I have the following Bootstrap markup:
<!-- Text input-->
<div class="form-group">
<label class="col-md-4 control-label" for="username">Username</label>
<div class="col-md-4">
<input id="username" name="username" type="text" placeholder="" class="form-control input-md" required="" maxlength="8" value="">
</div>
</div>
<!-- Button (Double) -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-8">
<button id="submit" name="submit" class="btn btn-primary" value="1">Create Profile</button>
<button id="cancel" name="cancel" class="btn btn-default" value="1">Cancel</button>
</div>
</div>
When I click the Create Profile button the form works fine letting me know that certain fields are "Required". But when I click the Cancel button I cannot leave the form due to incomplete required fields.
Is there a form cancel button capability in Bootstrap?
Change your code to the following:
<!-- Button (Double) -->
<div class="form-group">
<label class="col-md-4 control-label" for="submit"></label>
<div class="col-md-8">
<button id="submit" name="submit" class="btn btn-primary" value="1">Create Profile</button>
Cancel
</div>
</div>
simply set the type attribute to reset as shown below;
<button type="reset" class="btn btn-default pull-right">Cancel</button>
if you would like to keep both elements as <button>. You can create a click handler with jQuery:
$('#cancel').click(() => {
location.href = '../' //returns to parent
})
A direct method is to use onclick="history.back()" Like so:
<button id="cancel" name="cancel" class="btn btn-default" onclick="history.back()">Cancel</button>
It is supported in all browsers at the time of this posting
i don´t know why my web page reload when i add new register, the diference between next code is the form tag. Whith the first code the page is reloaded and the second code without form tag page isn´t reloaded, I can´t understand why. Could someone help me?
<div class="container" ng-controller="mybranchofficeCtrl">
<h2>Mis Salas</h2>
<!--newRoom input-->
<form role="form">
<div class="row">
<div class="input-group">
<input type="text" class="form-control" ng-model="room.rooms.name" placeholder="Crea tu Sala">
<span class="input-group-btn">
<input type="submit" class="btn btn-primary" ng-click="newRoom()" value="Añadir">
</span>
</div>
</div>
</form>
<p></p>
<p class="input-group" ng-repeat="room in rooms.data">
<input class="form-control" type="text" ng-model="room.name">
<span class="input-group-btn">
<button class="btn btn-danger" ng-click="disableRoom($index)" arial-label="delete">X</button>
</span>
</p>
</div>
but with this no, what is the diference?
<div class="container" ng-controller="mybranchofficeCtrl">
<h2>Mis Salas</h2>
<!--newRoom input-->
<div class="row">
<div class="input-group">
<input type="text" class="form-control" ng-model="room.rooms.name" placeholder="Crea tu Sala">
<span class="input-group-btn">
<input type="submit" class="btn btn-primary" ng-click="newRoom()" value="Añadir">
</span>
</div>
</div>
<p></p>
<p class="input-group" ng-repeat="room in rooms.data">
<input class="form-control" type="text" ng-model="room.name">
<span class="input-group-btn">
<button class="btn btn-danger" ng-click="disableRoom($index)" arial-label="delete">X</button>
</span>
</p>
</div>
these are controllers i´m using whith html code.
$scope.newRoom = function() {
$scope.room.rooms.branchoffice_id = $scope.branchId;
butlerService.createRoom($scope.room).then(function(newroom) {
$scope.rooms.rooms.push(newroom);
});
}
$scope.disableRoom = function(index) {
var delroom = {};
delroom = {rooms:{id:$scope.rooms.data[index].id}}
butlerService.deleteRoom(delroom).then(function() {
$scope.rooms.data.splice(index,1);
});
}
Thanks in advance.