jQuery UI datepicker icon is not clickable anymore after navigating to another page
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
One of my tabpage has jquery datepicker which loads the calendar when the icon is clicked. At first load, the icon is clickable (calendar appears). However when I select another tab(let's say tab2) then return back to tab1, the datepicker icon is present but the calendar does not display. Moreover, if I did this twice (click tab2 return tab1 click tab2 click tab1), the datepicker icon dissapears, and becomes like a normal input text box.
Here is my main jsp file:
and here's my code under tabpage 1:
Could someone please tell me what did I miss? I've spent a lot of time trying to find it.
Thanks!
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
One thing I can see that may explain why your button is disappearing is that your "buttonImage" needs to be a local file, not a URL. Without being able to test this I'm at a loss to explain why it's losing the "on click" binding when you change tabs. Bear will be hear in two or three hours. He'll probably spot the problem in about 3 seconds. I think he dreams in JavaScript.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Why is your script so fragmented throughout the page?
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
J. Kevin Robbins wrote:I think he dreams in JavaScript.
Some of my worst nightmares have been when I dreamt I was code.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks for your help. I am using a URL for datepicker because I read that it's recommended to use CDN to be more efficient? But I'll try to download the images to my local and locate it there. I'll update this later.
@Bear
Thanks for helping. I put a sysem.out.println both inside the datepicker javascrpt function and after the html tag for datefrom. They are both invoked when I switch from different tabs but on the page they are not working anymore.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I think I know the reason why does it happen but still could not figure out how to fix it.
I think the reason is because when I navigate from one tab to another, the tab page/whole page does not "refresh" or re-load. Since the tabpage with datepicker associated is in seperate jsp, the javascript is not being applied.
Is it possible to re-apply the javascript on selected components?
BTW, I am not using codes from ditchnet.. I just imported the library. I am using the jquery tabs.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
I would start by moving all that JS code to an external file that's wrapped withing one document ready function. Also checked out this link that talks about using the tab load event to bind the datepicker.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
This is the tabtest.js file
This is just a simple html file, no jsp, no server required. Notice that no matter how many times you change tabs, the DatePicker still works. Now use this example to fix your code, starting like I said, by moving all that random JavaScript into an external file wrapped in a single document.ready function.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Bear, is there any functional difference?
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Actually, I initially make the tabs under one jsp.. I encountered some problems:
1. I need to display a dropdown where it's values are inside a servlet/list. The values came from the database. Since
2. And also, there's a table in that page. When the user navigates back to that tabpage, I have to reset it's value. I've accomplished it by setting the table state of my bean to null.
But if I'll put all tabpages under 1 jsp, I can't find a way to do this.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
2. Why does anything need resetting? When the tab pane is revealed it should still have whatever values it originally had.
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
Start with the code I gave you until you get the first tab working and tested. Then slowly start adding the second tab, testing as you go. When you get unexpected behavior, STOP, come here with your code and let's work on it again. At this point you've worked yourself into a corner and you're going to go crazy trying to fix your existing code.
And once again, stop doing embedded JavaScript. One external file wrapped in a document.ready() function is where all your JS should be.
"The good news about computers is that they do what you tell them to do. The bad news is that they do what you tell them to do." -- Ted Nelson
| What does a metric clock look like? I bet it is nothing like this tiny ad: The new gardening playing cards kickstarter is now live! https://www.kickstarter.com/projects/paulwheaton/garden-cards |













