Giter Site home page Giter Site logo

Comments (9)

dhh avatar dhh commented on August 16, 2024

How is the datepicker currently initialized? Using jQuery.ready?

from turbolinks-classic.

davydotcom avatar davydotcom commented on August 16, 2024

No, it just runs. and sets initialized = false;

If initialized = false it recreates the date picker div. If initialized = true, .datepicker() on an object will not create the div.

It's kinda lazy initialized.

On Oct 5, 2012, at 9:56 AM, David Heinemeier Hansson [email protected] wrote:

How is the datepicker currently initialized? Using jQuery.ready?


Reply to this email directly or view it on GitHub.

from turbolinks-classic.

davydotcom avatar davydotcom commented on August 16, 2024

Also,
I looked into firing document.ready() as an event for jQuery, but unfortunately jQuery removes the events from the event listener as they are fired from the ready event. So there is no way to re-fire those events.

On Oct 5, 2012, at 9:56 AM, David Heinemeier Hansson [email protected] wrote:

How is the datepicker currently initialized? Using jQuery.ready?


Reply to this email directly or view it on GitHub.

from turbolinks-classic.

ryanflorence avatar ryanflorence commented on August 16, 2024

The jQuery datepicker initializes on the first call to $.fn.datepicker, and then sets a global variable to true.

https://github.com/jquery/jquery-ui/blob/master/ui/jquery.ui.datepicker.js#L1816-1820

@davydotcom's solution will bind the mousedown event with every page load, which is terrible.

You just need to append the element to the document again:

jQuery.datepicker.dpDiv.appendTo( jQuery('body') );

... or open tickets with jQuery UI (and everybody else in the world) to jump hoops to decide if their widgets have been blown away or not :P

from turbolinks-classic.

davydotcom avatar davydotcom commented on August 16, 2024

Ah, thanks

On Oct 18, 2012, at 10:52 PM, Ryan Florence [email protected] wrote:

... or open tickets with jQuery UI (and everybody else in the world) to jump hoops to decide if their widgets have been blown away or not :P

from turbolinks-classic.

davydotcom avatar davydotcom commented on August 16, 2024

Actually there is already a ticket and pull request for the date picker to fix this bug anyway. The bug is the fact that if the dpDiv does not exist in the body, to readd it.

This affects more than just turbolinks, it apparently affects some other edge cases as well.

On Oct 19, 2012, at 8:05 AM, [email protected] wrote:

Ah, thanks

On Oct 18, 2012, at 10:52 PM, Ryan Florence [email protected] wrote:

... or open tickets with jQuery UI (and everybody else in the world) to jump hoops to decide if their widgets have been blown away or not :P

from turbolinks-classic.

ryanflorence avatar ryanflorence commented on August 16, 2024

@davydotcom, nice, they have a pull request open too:

Bug tracker

http://bugs.jqueryui.com/ticket/5679

pull request

jquery/jquery-ui#543

from turbolinks-classic.

rafalbromirski avatar rafalbromirski commented on August 16, 2024

I know that this ticket is closed but I solved this problem in different way:

$(document).on 'page:change', ->
  $.datepicker.initialized = false

It works like a charm.

from turbolinks-classic.

davydotcom avatar davydotcom commented on August 16, 2024

This was originally mentioned in the issue, however it causes the date
picker to add multiple event listeners

On Wednesday, December 19, 2012, Rafal wrote:

I know that this ticket is closed but I solved this problem in different
way:

$(document).on 'page:change', ->
$.datepicker.initialized = false

It works like a charm.


Reply to this email directly or view it on GitHubhttps://github.com//issues/76#issuecomment-11527748.

from turbolinks-classic.

Related Issues (20)

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.