Solved

Apply DatePicker to element loaded by innerHTML

Posted on 2009-05-08
1
830 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

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

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
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)

777 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