Hey guys,
I have a problem in Safari with the following code and JQuery 1.6.

I have an <ul> list where each element contains a <form> which I show/ 
hide when the user clicks on the respective list item. I also have  
prev/next buttons which make an AJAX call and inject the HTML with  
the new list items. Upon updating the list, I also update the event  
handlers for the new DOM nodes so they have the same desired behavior.

This works in FF and Opera but after updating the list (and the event  
handlers) in Safari, show/hide doesn't work anymore. The are no JS  
errors or warnings of any sort. I traced the problem as deep as I  
could and found the following:
1) Event handlers are called
2) Within the event handler, $("#" + id + " form") returns an object,  
but the subsequent .toggle("slow") doesn't do anything

Here is a link to a development machine: http://trec.dachev.com/? 
q=trecmillion/queries

Please don't let the numerous references to the word "query" confuse  
you; This application is serving an Information Retrieval experiment.

Your help is greatly appreciated. Thanks,
Blago


                function getQueryPage(e) {
                        e.preventDefault();
                        
                        $.getJSON(this.href, function(json) {
                                // Process the list of queries
                                var newQueriesHTML = json.msg.data.html;

                                // Hide PREV/NEXT links
                                $(".getNext").css({display: "none"});
                                $(".getPrev").css({display: "none"});
                                
                                // Show the new list of queries
                                $("#queryList").html(newQueriesHTML);

                                // Show/Hide criteria forms when user clicked 
on a query
                                $("[EMAIL 
PROTECTED]").click(toggleCriteriaForm);
                                
                                // Delete box description when user clicked on 
the textarea
                                $("[EMAIL PROTECTED] 
textarea").click(toggleTextarea);
                                
                                // Restore textarea description if empty
                                $("[EMAIL PROTECTED] 
textarea").blur(toggleTextarea);
                                
                                // Prevent form from collapsing, submit it 
instead
                                $("[EMAIL PROTECTED] [EMAIL PROTECTED]").click 
(submitCriteriaForm);
                                
                                // Update and show PREV/NEXT links
                                var nURL = $(".getNext").attr("href");
                                var pURL = $(".getPrev").attr("href");
                                $(".getPrev").attr("href", 
pURL.replace(/[0-9]+$/,  
json.msg.data.prev));
                                $(".getNext").attr("href", 
nURL.replace(/[0-9]+$/,  
json.msg.data.next));
                                
                                if(json.msg.data.next != 0)
                                        $(".getNext").css({display: "inline"});
                                if(json.msg.data.prev != 0)
                                        $(".getPrev").css({display: "inline"});
                        });
                }

                function toggleCriteriaForm(e) {
                        e.preventDefault();

                        var id = this.getAttribute("id");
                        $("#" + id + " form").toggle("slow");
                }
                
                function toggleTextarea(e) {
                        if(this.value == "")
                                this.value = "Please describe how are you going 
to judge the  
documents for this query...";
                        else if(this.value == "Please describe how are you 
going to judge  
the documents for this query...")
                                this.value = "";
                
                        return false;
                }

                function submitCriteriaForm(e) {
                        e.preventDefault();

                        var criteria = 
this.form.getElementsByTagName("textarea")[0].value;
                        if(criteria.match("Please describe how are you going to 
judge the  
documents for this query...")) {
                                alert("You need to describe you query judging 
criteria.");
                                return false;
                        }
                        
                        this.form.submit();
                        return false;
                }

                $(document).ready(function() {
                        // Create a loader status box
                        $("div#container").children().lt(1).before(\'<div 
id="loading"  
style="position: absolute; top: 12px; right: 0; padding: 0 10px 0  
10px; display: none; background-color: #f00; color:  
#fff;">Loading...</div>\');
                        
                        $("#loading").ajaxStart(function(){
                                $(this).show();
                        });

                        $("#loading").ajaxStop(function(){
                                $(this).hide();
                        });

                        // Hide criteria forms after the page is loaded
                        $("form.queryCriteria").hide();
                        
                        // Show/Hide criteria forms when user clicks on a query
                        $("[EMAIL PROTECTED]").click(toggleCriteriaForm);
                        
                        // Delete box description when user clicks on the 
textarea
                        $("[EMAIL PROTECTED] textarea").click(toggleTextarea);
                        
                        // Restore textarea description if empty
                        $("[EMAIL PROTECTED] textarea").blur(toggleTextarea);
                        
                        // Prevent form from collapsing, submit it instead
                        $("[EMAIL PROTECTED] [EMAIL PROTECTED]").click 
(submitCriteriaForm);

                        // Hijack PREV/NEXT navigation
                        $("[EMAIL PROTECTED]").click(getQueryPage);
                        $("[EMAIL PROTECTED]").click(getQueryPage);
                });

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to