Results 1 to 8 of 8

Thread: Bug in Jason's Date Input Calendar..I think

  1. #1
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Bug in Jason's Date Input Calendar..I think

    Hi, All,

    I'm using Jason's Date Input Calendar (found here at DD) in a to-do list web app, and it's giving me some fits.

    I have several forms that I move around the list dynamically to allow you to add items to list items in an ajaxy way. The trouble is whenever another form gets moved below Jason's Date Input Calendar in the Document model, the calendar loses it's refernce to the form. I get the message "this.getHiddenField()" is null or not an object.

    The other two forms are Contacts form and Add Sub-Item form. As long as I move them higher in the list (and document model), it works, but as soon as one fo those forms is below the calendar...ERROR!

    Would anyone know how to get the calendar attached to my Calendar form by ID instead of using THIS.

    If you want to try it for yourself, you'd need to create an account for yourself at www.SugarDo.com. I haven't built the public list feature yet. [ Note: I have made a work around by moving all the other forms up upon showing the calendar form. Would still like to get this fixed. ]

    Any help would be great! Best regards,
    Byron
    Last edited by bennebw; 08-03-2007 at 03:03 PM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    That probably isn't a bug. You are inserting elements to the page and possibly removing one or more as well. This could throw off the the order of, and possibly the value of and/or end the existence of other elements. When you say 'ajaxy', that doesn't tell us much. If you are using innerHTML at all, that will only compound matters, especially with form elements. That's because even replacing an existing form element that you are wiping out with the innerHTML method often results in the document tree not recognising it in the same way any longer. This will happen all the time in any script that initializes an element like that onload. Even relying solely on DOM methods like createElement and appendChild, if you wipe out something that the script needs or change the order of elements in any case where the script is relying upon that order, it won't be happy.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Hi, John. Thanks for your reply.

    Here's a bit more info:

    One thing I should note is that after much tinkering I finally determined what the problem was by removing the contact form from my code. In my development, I had added the AddDueDateForm before adding ContactForm. This worked fine, as AddDueDateForm was the last form in the Document model. A week later, I added the ContactForm. It took me a week to realize that DueDate had stopped working. The ContactForm was in the original HTML below AddDueDateForm. Even without doing any dynamic movements in the Client browser, the Calendar wouldn't work. So I rebuilt my code to add ContactForm before AddDueDateForm in the original HTML. That fixed it until I moved those forms around dynamically.

    All form movements are done using Prototype's Move method. We can eliminate this as the problem since it doesn't work when the contact form shows up below the duedate form, even without using the move method.

    No innerHTML is used in manipulating the forms. Just using Prototype's Move, Hide, Show methods, plus "display: none;".

    I imagine that if you added a form to the bottom of the demo page on dynamic drive, it might experience a similar issue. Either that, or I'm doing something pretty whacked out.

    Thanks for your help!

    Byron

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Without investigating the methods used by prototype.js, there is no way to be certain what it is doing. If adding a form after the form that was previously working messes things up, that would be strange indeed, unless the added form contained an element that could be somehow confused with an element from the first form. Adding or moving something before a previously working form or moving the working form after another form could, for a variety of reasons cause a problem.

    If these forms that you are talking about have scripts associated with them for processing or display purposes - aside from any moving - these scripts could be in conflict.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Aug 2007
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    John,

    I did a brief test adding just two forms on a page and the calendar works fine regardless of the order, so that doesn't appear to a proble.

    Evidently, I've got something going on in my scripts that are conflicting. The workaround I have is working fine (dynamically moving (and hiding) the AddItemForm and ContactsForms to the top of the document whenever the DueDateForm is shown - for some reason this works fine.), so I'm going to go with that.

    I appreciate your help!
    Byron

  6. #6
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Talking Solution to problem

    Hey guys,

    I have a great solution for this problem that works for me. I simply added a parameter which is FormName. You pass in the name of the form that contains the calendar component now and this is used to keep track of the appropriate form/date component.

    I also needed to change the function for generating the component to accommodate the extra parameter (the original code checks the number of attributes during generation).

    The updated .js file is attached.

  7. #7
    Join Date
    May 2012
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    ivanpointer,

    I just ran into this same problem on my site and tried out your updated js file, and it worked like a charm. Thanks for posting this!

    After several days of pulling my hair out trying to figure out why my data was not being submitted properly, this solution fixed everything beautifully.

    Just wanted to say "thank you" since no one else has yet.

  8. #8
    Join Date
    Jun 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I am glad it was of use!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •