Solved

cfdiv jquery datepicker

Posted on 2014-12-15
12
94 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Report: Liquid Web beats Amazon, Rackspace & More

A study by performance analyst firm Cloud Spectator finds that Liquid Web beats rivals Amazon, Rackspace and DigitalOcean when it comes to website and cloud application performance.

Question has a verified solution.

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

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
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 how to dynamically set the form action using jQuery.
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)
Suggested Courses

732 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