GithubHelp home page GithubHelp logo

arschmitz / jquery-mobile-datepicker-wrapper Goto Github PK

View Code? Open in Web Editor NEW
58.0 58.0 62.0 483 KB

Wrapper to turn jquery ui datepicker into a mobile widget.

License: MIT License

CSS 64.81% JavaScript 35.19%

jquery-mobile-datepicker-wrapper's Introduction

jquery-mobile-datepicker-wrapper

Wrapper to turn jquery ui datepicker into a mobile widget.

This takes the jQuery ui datepicker and turns it into a fully functional jquery mobile widget. This includes auto initalization via data-role="date" and reading of options from data-attributes. For example usage please see http://jsbin.com/uzaret/1375/edit

  • Compatible with jQuery Mobile 1.4+

  • Please note: this widget is called date not datepicker so when calling methods you must use $(element).date("method"); other then this all jquery ui functionality is the same and you can see jquery ui api for usage http://api.jqueryui.com/datepicker/

jquery-mobile-datepicker-wrapper's People

Contributors

aka-ani avatar arschmitz avatar indrimuska avatar phillipsenn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-mobile-datepicker-wrapper's Issues

Datepicker jQuery UI API not working after "wrapping"

Working code (part of Wordress template) looks like:

<link type="text/css" href="/css/custom-theme/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>
jQuery(document).ready(function() {
     jQuery("#dataStart").datepicker({

        minDate: '+2d',
        changeMonth: true,
        changeYear: true,
        dateFormat: 'mm/dd/yy',
        onSelect: function(date){
            var dates = date.split('/');
            var lastDate = new Date(dates[2], dates[0], 0);
            var y = lastDate.getFullYear(), m = lastDate.getMonth(), d = lastDate.getDate();
            m = ('0'+ (m+1)).slice(-2);

            jQuery('#dataEnd').val(m+'/'+d+'/'+y);

            var start = jQuery('#dataStart').datepicker('getDate');
            jQuery('#dataEnd').datepicker({dateFormat: 'mm/dd/yy'}).datepicker('setDate', m+'/'+d+'/'+y);
            var end = jQuery('#dataEnd').datepicker('getDate');
            var days   = ((end - start)/1000/60/60/24)+1;

            jQuery('#calculated').text(days);          
        }
    });
});
<tr>
<td width="123" height="25" style="text-align: right;"><label for="dataStart">Start Date:</label>&nbsp;</td>
<td align="left" valign="top" class="copy11"><input type="text" style="width: 88px;" class="datepicker" id="dataStart" size="10" name="dataStart" data-role="date" /></td>
</tr>
<tr>
<td width="123" height="25" style="text-align: right;"><label for="dataEnd">End Date:</label>&nbsp;</td>
<td align="left" valign="top" class="copy11"><input type="text" style="width: 88px;" class="end_date" id="dataEnd" size="10" name="dataEnd" value="" readonly /></td>
</tr>

and when I use your solution to have it "mobile friendly" datepicker jQuery UI API is not working as well is not really "mobile friendly"

Cannot change theme

data-theme attribute doesn't work (the wrapper doesn't have a method to set the theme)

Calendar widget is transparent

This seems to be similar to jquery-archive/jquery-mobile#6952

Here's what I see after accessing http://jsfiddle.net/FUGZN/ or http://jsbin.com/uzaret/1375/edit (before and after focusing on 1st input field)

image

Same happens when I try to use your plugin on my own page (sorry, can't share a public link as it requires authentication).

It can be fixed by adding CSS like <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"/>

however I've noticed this will bring too much of jQuery UI for me and will screw up other things like jQuery Mobile tabs.

I think you've externalized the jquery.mobile.datepicker.theme.css but didn't include it in the demos? Adding <link> to that file seemed to fix it for me although I'm not sure if it looks as it should:

image

The reason I'm not sure how the datepicker should look like is that I've been temp. banned from rawgit.com for viewing the demo page too much I guess. Apologies if this ticket is written up in an unclear way or if it should be logged in against jQ M docs...

Getting a change event from a datepicker object

Due to the fact that by default you catch onSelect, change and input events it seems I can't attach a handler to any event in order to know when the field value changes. The only solution I found is to trigger a change event from your onSelect handler:

object.input.trigger("change");

Flicker with inline date picker

Hello,

I've been working with inline date pickers with jquery mobile 1.4.2 and there's a noticeable flicker when selecting dates or changing months. It looks like it's being caused when the wrapper .js is adding the mobile style. Is there a way around this flicker?

I thought it might be an issue in my code, but the flicker is present even in the datepicker-wrapper demo here: http://jsbin.com/uzaret/1375/edit (I observed the flicker in Chrome 34.0.1847.116 on OS X 10.9 and Firefox 28 on OS X 10.9).

Any help or ideas would be great. In the meantime, I'll look to see if I can develop a workaround.

Thanks,
-Justin

getDate always returns null

Using jQuery Mobile 1.4.0, I have the following:

var date = $("#date").date("getDate");

and every time it returns null.

I can use

var date = $("#date").datepicker("getDate");

and it works just fine. I was led to believe by the notes in the readme and the actual code that this wasn't necessary.

Popup month change

I've found a wee issue when changing the month selection on the popup control. The popup appears to lose all styling. I worked around by setting altField equal to this.element in the _create method.

Dave

datepicker highlight today's date

sorry i posted last time in the bug section... but i have another question.
how do i get the datepicker to pop up with today's date highlighted?

thanks!

Set Dateformat

$(function(){
$("#gebdat").date({ dateFormat: 'yy-mm-dd', maxDate: '0', minDate: new Date(1950, 1 - 1, 1) });
});

This is the code to change the shown dateformat? Because I want to display the date 2014-04-11 and not 04/11/2014.

What is wrong with my code? Pleas help.

onSelect

Hi,

I don't understand how to use onSelect property with jqm datepicker wrapper.

Can you help me please ?

Regards.

Error with Jquery 2.0.3

I am getting the following error with the Jquery 2.0.3 library:

[Error] TypeError: 'undefined' is not an object (evaluating '$(object.settings.altField).data("mobileDate")._addMobileStyle')
    (anonymous function) (jquery.mobile.datepicker.js, line 35)

Also I cannot seem to get the method calling working. The readme says: $(element).date("method"); but what is the element called? I tried the ID of the input field but thats not working.

Manually typing a date is broken

date_picker_issue
Manually typing a date into the datepicker is completely broken in all browsers. The version I tested with was jquerymobile 1.4.0.

I found the demo useful and copied the usage on to my own site, and during testing I found this issue. I discovered it also is present in the jquerymobile demo site.

Steps To Reproduce:

  1. Open browser of choice
  2. Go to: http://demos.jquerymobile.com/1.4.0/datepicker/
  3. Focus into any date picker and try typing in "01/01/2014"

Expected Behavior:
You should be able to type in the entire date without interruptions.

Actual Behavior:
After typing the "2" in "2014" the widget tries selecting "2002", then you end up with a date like "01/01/2002014" - Using backspace is no use, it keeps trying to select the date for you.

Also there is some weird behavior causing the background on the calendar to disappear.

JQM 1.5 and JQuery 3

Is this wrapper compatible with the newest versions of jquery?
In the demo it throws:
TypeError: $.event.props is undefined

Help

i moved your root folder to my Dropbox and opened index.html in both Chrome and Firefox on my Note 3 and neither show the calendar. they both look identical though with the input boxes, header and footer. the input box selection css seems to be working. i have js enabled on both browsers and pop up blocker off.

Thanks!

Change event not firing

When selecting a date, the change event is not firing. This makes it difficult to use with data binding libraries. Is there a workaround or fix for this?

Performance issue?

I know the lack of including any Fiddle won't go down well around here, but I thought I'd bring this strange issue to your attention.

I am generating this datepicker dynamically using the code:

$('<input>')
.attr({
    'type': 'text',
    'id': id,
    'name': id,
    'placeholder': 'DDMMYYYY',
    'data-inline': 'false',
    'data-role': 'date'
})
.on('input', update_form) // refreshes various elements on my page after the user changes date
.date({
    firstDay: 1,
    dateFormat: 'ddmmyy'
})

I am making this call many times because my app requires the user to enter a date on many occasions. Unfortunately this call must be made dynamically because it isn't possible to hard-code when it is used (AJAX/JSON requests to our server determine when the date picker is required).

I have noticed that when the user has clicked the input box (which brings up the date picker) the performance of my app slows dramatically. Further clicks of the input box slows the app further until the point where it becomes unusable. It seems that it is when the datepicker is shown to the user that the performance is affected, not when the element is created using the above code.

The performance impact on desktop browsers is generally unnoticeable, however on mobile devices, such as my Lumia 1020 and iPhone 4s, it is noticeable within a couple of datepicker operations.

I tried using the following call to clear the element from the DOM, after the user has finished selecting dates to no avail:

$('.ui-datepicker').remove();

Sorry again for lack of fiddle, but any ideas?

code cleanup

follow jQuery style guide at contribute.jquery.com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.