aspose file tools*
The moose likes HTML, CSS and JavaScript and the fly likes jQuery UI Widget issue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "jQuery UI Widget issue" Watch "jQuery UI Widget issue" New topic
Author

jQuery UI Widget issue

Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

Guys,

I have a page rendered using jQuery UI. I have a next button and on click of the next button, I load a div element whose contents are rendered using a jsp. But what I have noticed is that after a couple of clicks of the next button, I get to see the following error:


Is this a bug with jQuery?


SCJP 1.4, SCWCD 1.4 - Hints for you, Certified Scrum Master
Did a rm -R / to find out that I lost my entire Linux installation!
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

I'm investigating the potential cause to this issue. Following is the snippet that submits the form:



My question is, since this is called on document ready, is this return false alone enough to prevent the form being submitted again and again?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Have you observed the Ajax and request behavior using tools such as FireBug and HttpFox?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

Every click of the next button sends 2 requests to the server. From where is the second request originating?
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

My guess is that the else part could be playing foul?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61437
    
  67

Without details, I can't guess.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Just a side note, the $(this) over and over again is BAD practice. Each time $(this) is called it has to create a new instance and do the lookup. Store it once into a variable and reuse it.

Eric
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
I think the problem here is this line



fadeOut is NOT synchronous, it has a callback.

Eric
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

Thanks for the suggestions. I have already removed the fadeIn and fadeOut calls. Will modify the function to avoid calling $(this) repetitively.
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

I guess here the form is submitted twice for each click. Once when the next button is clicked and then after page load. Is there a way to avoid the second submit?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Are you saying the whole page is submitting?

preventDefault()

Eric
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

Eric Pascarello wrote:Are you saying the whole page is submitting?

preventDefault()

Eric


I'm not sure if it is the whole page, but I get to see the alert message being called twice for each click of the next button.

Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Do you realize that this line:



is in the wrong location?

If the code is being called twice, are you sure somehow it is not being hooked up twice. Do you have an invalid html markup with two nested forms?

Eric
Joe Harry
Ranch Hand

Joined: Sep 26, 2006
Posts: 9427
    
    2

Eric Pascarello wrote:Do you realize that this line:



is in the wrong location?

If the code is being called twice, are you sure somehow it is not being hooked up twice. Do you have an invalid html markup with two nested forms?

Eric


Shoudn't in be inside the document ready function? I have two different forms on my page with different id and based on the id, I determine which div to update.

I chcked my rendered HTML amd I do not see any nested forms.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: jQuery UI Widget issue