Choosing a Date using a DateTimePicker

I recently implemented a directive in my HTML for selecting dates, and I'm struggling to add time slots to it. Here is the code snippet:

JSFIDDLE

angular
    .module('App',['ui.date'])
    .directive('customDatepicker',function($compile){
        return {
            replace:true,
            templateUrl:'custom-datepicker.html',
            scope: {
                ngModel: '=',
                dateOptions: '='
            },
            link: function($scope, $element, $attrs, $controller){
                var $button = $element.find('button');
                var $input = $element.find('input');
                $button.on('click',function(){
                    if($input.is(':focus')){
                        $input.trigger('blur');
                    } else {
                        $input.trigger('focus');
                    }
                });
            }    
        };
    })
    .controller('myController',function($scope){
        $scope.birthDate = '2013-07-23';
        $scope.dateOptions = {
            minDate: -20,
            maxDate: "+1M +10D"
        };
    });

My goal is to be able to select time slots within this DatePicker, such as $scope.time='00h-12'. Unfortunately, I haven't been able to figure out how to implement this feature.

Answer №1

To enhance the functionality of your customDatepicker directive, you have the ability to directly modify the datepicker element itself, such as by using

$.datepicker.dpDiv.append($("#custom-footer").contents().text());
. Refer to line 21 in the linked jsfiddle for an example.

Additionally, in accordance with the approach you are following, I included the custom footer text within a template enclosed in a script tag; this can be seen on lines 7-10.

For the updated solution, visit: http://jsfiddle.net/haroldcampbell/FVfSL/808/

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Can JSON data be exported to docx, pdf, and excel files using node.js or client-side JavaScript?

I have been searching for a method to export JSON data into three main formats, including docx, xlsx, and pdf. Thus far, I have managed to achieve this in Node.js: var data = req.body["exportData"]; var headers = req.body["exportHeaders"]; var delimite ...

When Ajax attempts to run a PHP page, it redirects me to a different page

My goal is to create a live chat feature using PHP, MySQL, and AJAX. I have almost got it working perfectly, but I'm stuck on how to submit the chat message without refreshing the page. I have a PHP page called sendchat.php that takes input data and s ...

Retrieving data from a popup window with php and javascript

I've been working on creating a pop-up page that will return a value to the parent page and then close. Here is what I have done so far: Main.php: <tr> <th>Project Name</th> <td><input type="text" name="project_name" id="p ...

Struggling to construct the Angular 2 project from GitHub

After forking the Angular 2 GitHub repository, cloning it to my desktop, adding upstream, and running npm install, I encountered an issue when attempting to build ($(npm bin)/gulp build). The error message displayed was: "Task 'build' is not i ...

Showing user avatar icon with automatically generated name initials

I am looking for a way to generate an avatar icon based on a person's name. The icon should consist of the first letters of each word in the name. For example, if the name is John Abraham, the icon should display 'JA'. I plan to use this av ...

The Bootstrap 4 Carousel experiences flickering issues during transitions when viewed on Safari browser

After integrating a Bootstrap 4 carousel onto a Drupal platform, I encountered a peculiar issue. The carousel functions smoothly on Chrome, but on Safari, it briefly blinks before transitioning to the next slide (as per the set interval time). Initially, I ...

Error message: "The URL retrieved from the JSON data is being displayed as undefined in a

I encountered an issue while following this tutorial. I am attempting to load an image from a JSON-formatted URL. Despite following the tutorial correctly, I am unable to get the image to load. Upon using react-tools, I noticed that the url field is displ ...

Reactive Form value is not displaying in view because of FormControlName issue

I have successfully retrieved data from the database and need to pre-fill an update form with preset values. The issue I am facing is that when I add FormControlName to the input field, it removes the preset values. I have tried using setValue and patchV ...

Preserve the variable alterations for future promises

I have implemented promises in my database access using elasticsearchjs, which utilizes Bluebird. Each ID in the list triggers a new query, and I need to identify the failing query by its ID. const idList = ['id1', 'id2', 'id3&apo ...

404 Error: The requested resource is not available on the web API

I have been attempting to utilize Web Api to send/receive data from the server. In my WebApiConfig.cs file: config.MapHttpAttributeRoutes(); config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "{controller}/{act ...

Conceal the div on larger screens and display it on mobile devices

I have a fixed navigation bar at the top of my website. By default, it is always visible on all pages, but I want to hide it on desktop screens and display it only on mobile devices. Here is what I have implemented: @media (min-width: 992px) { #sp-he ...

Trouble implementing array filter in React component is a common issue

Hello everyone! I'm facing an issue with deleting an element from my useState array. I have the index of the element that I want to remove, and I've tried the following code snippet: const updatedArray = myArray.filter((item: any, index: number) ...

How can I reduce the delay in Angular 5 to a minimum?

The following code represents a simple request function: getItem() { return this.http .post<ItemModel>(`${this.apiUrl}/${methodUrl}`, {}) .subscribe(response => { ... }); } Depending on the duration of the ...

Utilizing the power of AngularJS directives along with the functionality of a

I am completely new to angular js, but I have successfully integrated a jQuery UI datepicker into my Angular JS project. Now, I am facing the challenge of formatting the date selected by the jQuery datepicker into ISO date format. Here is the code snippet: ...

Button click does not fill in Jquery Datepicker?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <link type="text/css" href="Styles/Site.css" rel="Stylesheet" ></link > <script type="text/javascript" src= ...

Correct validation is not achieved when the "!" symbol is used in the matches function

I am working on a React and Next.js project where I am using Formik for handling forms and Yup for validations. One specific input field requires some validations to be performed. This field must be required, so if the user does not enter any information, ...

Tips for incorporating additional filter criteria into a jquery script

I am currently utilizing a jQuery script to filter data based on date periods. However, I now need to include an additional filtering criteria for the "POSITION" column. Since I lack expertise in jQuery, I would rather accomplish this using plain vanilla J ...

Angular.js: Utilizing ng-model for checkboxes

Here's the code for my project: <input type="checkbox" ng-model="variable"> In this scenario, the variable will hold either true or false based on the checkbox status. However, I want it to store "+" instead of true and "-" instead of false. W ...

Why does my progress bar in React not begin on the left side and instead starting in the middle? (See image for reference)

Image Having an issue with the scrolling progress bar that seems to be stuck in the middle and moving in both directions, which doesn't look visually appealing. Can anyone suggest how to resolve this? Interestingly, the same code works fine on online ...

Encountered a 404 error while attempting to build and serve a Vue.js project using 'npm build' in Apache Tomcat

After setting up a Vue.js project, the configuration in the package.json file looks like this: "scripts": { "serve": "vue-cli-service serve", "build": "vue-cli-service build", "lint": ...