Solved

cfdiv jquery datepicker

Posted on 2014-12-15
12
91 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Jquery GMAP3 Hierarchy 1 24
Using jQuery to set a DIV attribute on page load 9 29
Restore of mysql database from .SQL file - using Coldfusion 5 34
Jquery 2 9
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
The viewer will learn how to dynamically set the form action using jQuery.
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…

776 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