Solved

Apply DatePicker to element loaded by innerHTML

Posted on 2009-05-08
1
828 Views
Last Modified: 2012-06-21
I've spend two days on this dilemma so I think I'm missing something fundamental in JS.  

I have a program which loads each individual page into a <div> tag on the parent page using AJAX.  This works great.  

Issue:
I'm trying to use vlaCalendar2.1 for a DatePicker on one of the pages and also need to use the drag and drop feature of scriptaculous to resort items in a list of checkboxes on another page.  Remember, all pages are shown in a <div> tag on the parent page using innerHTML. independently each works fine, but when I put all the <script> tags on the parent document and then try to use these features they have conflicting functions.

What I've tried:
I realize I should get them to work together in case I need them both for the same form, but I wanted to try to load the JS when needed then take it away,  createElement('script').  however, when I append the scripts to the head tag (synchronously -> 1,2,3) they do not apply the datepicker to the Text box.  

Trying this technique on a separate example without the AJAX functionality works.  BUT, in that same example when I try to create another textbox using createElement the datePicker does not apply to the new element even when i rerun the last part of the script:

alert('3');
window.addEvent('domready', function() {
new vlaDatePicker('exampleI', { format: 'm/d/y' }, { prefillDate: {} });
});      


Any ideas on what am I missing here???  Suggestions on a better way to do this?  A good library of JS scripts which contains a nice datePicker and way to sort a list of <div>'s or checkboxes???


thx in advance!
0
Comment
Question by:sixth_street
1 Comment
 
LVL 51

Accepted Solution

by:
ahoffmann earned 500 total points
ID: 24342709
> ..  they have conflicting functions.
your need to use unique function names , at least they need to be unique in a namespace
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
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 …
Learn the basics of strings in Python: declaration, operations, indices, and slicing. Strings are declared with quotations; for example: s = "string": Strings are immutable.: Strings may be concatenated or multiplied using the addition and multiplic…
The viewer will learn how to dynamically set the form action using jQuery.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now