Solved

cfdiv jquery datepicker

Posted on 2014-12-15
12
93 Views
Last Modified: 2015-01-27
I have a main page that has a cfdiv that is bound to some filter inputs on the main page.

<input name="SelectDate" type="text" class="datestuff">

<cfdiv bind="url:divPages.cfm?SelectDate={SelectDate}" id="pageDiv" bindonload="true" />

Open in new window


The datepicker stuff works fine but the bind to the input element doesn't work.  I've tried @blur and @mouseout but the timing is off.  If I don't use datepicker, the bind works fine, but datepicker is the default for the site.  

The datepicker code is;
function initDateStuff() {
			$(function() {
				$('input.datestuff').datepicker({
					dateFormat: 'yy/mm/dd'
				});
			});
		}

Open in new window


And at the bottom of the cfdiv page I have;
<cfset ajaxOnLoad("initDateStuff")>

Open in new window

0
Comment
Question by:lanterv
  • 7
  • 5
12 Comments
 
LVL 82

Expert Comment

by:leakim971
ID: 40502012
be sure to bind BEFORE setting the datepicker :
$('input.datestuff').on("click", function() { alert("first!"); });
$('input.datestuff').datepicker({....

Open in new window


and not :
$('input.datestuff').datepicker({...
$('input.datestuff').on("click", function() { alert("first!"); });

Open in new window

0
 

Author Comment

by:lanterv
ID: 40503426
I don't understand.  Where did " on.click" come from?  The datepicker doesn't work unless it's in the head.  Besides, CF generates the code for the bind and puts it where ever it wants.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40503451
OK so use a setTimeout to create your datepicker,
setTimeout(function() {
    $("input.datestuff").datepicker (...
}, 500); // 500ms before creating it
0
How our DevOps Teams Maximize Uptime

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us. Read the use case whitepaper.

 

Author Comment

by:lanterv
ID: 40503667
setTimeout(function() {
    $('input.datestuff').datepicker (dateFormat: 'yy/mm/dd');
}, 500)

Open in new window


Give me a syntax error:

SyntaxError: missing ) after argument list
0
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 40503763
you forgot the brackets...

setTimeout(function() {
    $('input.datestuff').datepicker ({dateFormat: 'yy/mm/dd'});
}, 500)

Open in new window

0
 

Author Comment

by:lanterv
ID: 40503786
That made the datepicker work.  But the cfdiv bind to the datefield doesn't work.
0
 

Author Comment

by:lanterv
ID: 40503798
Using cfinput type="datefield" or input type="date" doesn't work either.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40504033
did you try mousedown instead mouseout?
0
 

Author Comment

by:lanterv
ID: 40504129
Yes I did. Doesn't work.
0
 
LVL 82

Expert Comment

by:leakim971
ID: 40504433
time to share a link to your website, a simple onclick work fine : http://jsfiddle.net/w4jmbgqm/1/
0
 

Author Comment

by:lanterv
ID: 40505480
It's an internal admin site.  Not public.  Sorry.  I'll see what I can do about creating it on a public site.
0
 

Author Closing Comment

by:lanterv
ID: 40573978
Thank you
0

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Recently while working on a project I got a very annoying cfdocument has no body error message. I had never seen this error before. So I checked the code. The code was pretty simple; it was Just showing me the cfdocumnt tag and inside that tag a …
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question