logo
down
shadow

jQuery UI Datepicker onClose: distinguish between date click and document click


jQuery UI Datepicker onClose: distinguish between date click and document click

By : Ahmed Saifuddin
Date : November 19 2020, 01:01 AM
this will help I have a datepicker with an onClose function that is called when user select a date (correct), but also when the calendar is shown but user clicks anywhere in the document (wrong). , How about this
code :
$(function () {
    $('#datepicker').datepicker({
        closedBySelect:false,
        onSelect: function (date, options) {
            alert('fired when selected');
            options.settings.closedBySelect = true;
        },
        onClose: function (date, options) {
            alert('fired on close');
            if (options.settings.closedBySelect) {
                console.log('logic when closed on select');
            } else {
             console.log('logic when closed on document click');
            }
            options.settings.closedBySelect = false;
        }
    });
});
$(function () { 
    var datePicker = $('#datepicker');
    datePicker.data('closedOn','document').datepicker({
        showButtonPanel:true,       
        onClose: function (date, options) {          
            alert($(this).data('closedOn'));  
            //  your logic goes here ...
            $(this).data('closedOn','document');
        }
    }).datepicker('widget').on('mousedown',function(event){
        var $this = $(this);
        var target = $(event.target);      
        if(target.hasClass('ui-datepicker-close'))
        {
            console.log('closed from button panel');
           datePicker.data('closedOn','byButtonPanel');
        }
        if( typeof target.parent().data('month') != 'undefined')
        {
            console.log('closed by selecting date');
            datePicker.data('closedOn','byDateSelect');
        }      
    });    
}); 


Share : facebook icon twitter icon
jQuery: datepicker, auto click /pick a date

jQuery: datepicker, auto click /pick a date


By : chris_magento
Date : March 29 2020, 07:55 AM
around this issue According to the docs, datepicker provides is a setDate method:
code :
$('#datepicker').datepicker('setDate', '2012-02-02')
How to distinguish between mouse click and .click() in javascript/jquery?

How to distinguish between mouse click and .click() in javascript/jquery?


By : TuoYing
Date : March 29 2020, 07:55 AM
may help you . In javascript/jquery, I have a button that have a click event defined like: , You could use this:
code :
$("#target").click(function(e) {
    var mouse_click = !(e.originalEvent === undefined);
    // do stuff
    if (mouse_click) {
        // do stuff  
    }
    // do stuff
});
var mouse_click = !e.isTrigger;
Jquery datepicker: disable click on date

Jquery datepicker: disable click on date


By : Soulcat1
Date : March 29 2020, 07:55 AM
this will help I'm using JQuery Datepicker and I only want the datepicker being hidden, when click on "Done" button. , Thank to charlietfl,
Inline approach was the way to proceed.
Get alert on click datepicker date using jquery

Get alert on click datepicker date using jquery


By : P. Jocosus
Date : March 29 2020, 07:55 AM
this will help , Simply if you use JQuery you can use 'onSelect' event like
code :
 $("#datepicker").datepicker({
    dateFormat: 'dd M yyyy',
    onSelect: function(dateText){
         // write your logic here 
        }
});
JQuery binding to document click handler on object click triggers document click handler immediately

JQuery binding to document click handler on object click triggers document click handler immediately


By : seanericknight
Date : March 29 2020, 07:55 AM
I wish this helpful for you I wrote a click handler that creates a binding to the document click handler like so: , try this:
Related Posts Related Posts :
  • javascript - explanation request of a behaviour
  • Converting String into date format in JS
  • Choose element Angular
  • Display background grid by using image with CSS
  • Call function from another Controller in another file AngularJS
  • How to change texture in Gera library?
  • When trying to use windows.location.href , the values of $_POST[''] is lost
  • jQuery click action on appended item
  • NodeJS & Socket.IO: Emit a request event and get the response, when/where should I bind the listener?
  • 4-digit form on bootstrap modal
  • Prevent characters like quotation marks from input
  • Sign in option creation using jsp and oracle database
  • use socket.io in my controller with yeoman
  • What happens under the hood to prevent calling a bound method changing the this object?
  • issue with jquery .append function
  • Is it possible to EventHandle every GET request a page makes via Javascript?
  • How to select class with ng-if
  • Cannot communicate with websocket. Autobahn: received HELLO message, and session is not yet established
  • Socket.io - Cannot connect to client
  • Load Accordian Panel on click rather than page load
  • How to register async middleware module within express.js app?
  • JS / Cannot read property 'push' of undefined
  • how to make jquery plugin?
  • MATH reverting rotated coordinates
  • Add an expandable text box to every post
  • What was the rationale behind having the receiver in functions default to the global object?
  • JavaScript chaining many function
  • while loop over takes the each method
  • What are the difference between $(document).bind('ready', function) and $(document).ready(function() {})
  • cut the string in javascript
  • Tool tip not working on text area bootstrap
  • AngularJS: how to activate first non zero item in ngRepeat?
  • Pattern for "column total" of an array of arrays
  • Any selector using * failed in my case
  • Uncaught ReferenceError: app is not defined in Angularjs
  • Unit testing controller which has a $state.go method in controller
  • Use of Meteor-ui-progress-circle (accessing to Template variables created in the HTML)
  • JavaScript: Google maps mapOptions?
  • How do I track Universal Analytics events through Google Tag Manager?
  • Firefox Scrolling Bug When Changing :after Contents
  • Drop down list does not work
  • Display month and year specific datepicker in jquery
  • How to show BAr graph rather than line graph in High Stoch Chart
  • Accessing Angular $Scope in web workers
  • How to convert JavaScript(UnityScript) to C# and implement a low pass filter?
  • Need a logic to implement select button value via onchange event
  • redirect in codeigniter using ajax function
  • How to populate this form data and post it with jquery
  • Retrive value from array id in js function
  • angularjs $index when ng-hide with ng-repeat
  • ExtJS TaskRunner
  • Progress bar not hiding after fetching values via AJAX in JavaScript
  • Pop up window code fails
  • how to make dynamic javascript array with key and value group
  • Implement Facebook API login with reactjs
  • What is the meaning of sign ':' in javascript
  • Change all id's in HTMLDivElement using jQuery
  • load multiple pages from different domain in different divs using javascript
  • Could Not Resolve Host github.com
  • jQuery "Chosen" on-filter event?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org