tags:

views:

66

answers:

1

I have a page that has a jquery AJAX function

$(document).ready(function() { 
        var options = { 
            target: '#return',
            beforeSend: function() {
                $('#processing').show();
            },
            complete: function() {
                $('#processing').hide();
                $("#SymbolSearchResults tr:even").addClass("SSOdd");
                $("#previous").click(function(){ changestart('back'); });
                $("#next").click(function(){ changestart("forward"); });
                $("#lookup").click(changestart);
            }
            }; 
        $('#SymbolSearchForm').ajaxForm(options); 
    }); 

    function changestart(direction) 
    {
        var rowsElement  = $("#maxrows");
        var rowsValue    = parseInt(rowsElement.val());
        var startElement = $("#startID");
        var value        = parseInt(startElement.val());
        startElement.val(direction == "forward" ? value + rowsValue : direction == "back" ?
value - rowsValue : 1);
    }

</script>

I was having trouble rebinding the click handlers to the #next, #lookup and #previous as well as the class SSOdd to the table #SymbolSearchResults tr:even. I fixed it by adding it into the complete function. However I cannot apply any styles to the target div #return. I can style elements in the #return by ID, but again, nothing to the #return div itself. Is there a solution to this? I can only style the div by using inline CSS in the html page, not desired. I also think maybe I should use the .live function for the click functions inside the complete function? can you add a class with .live?

Please help unf**ck my code!

thx

A: 

It doesn't appear to be linking via the ID identifier as you said, but I can change the class of that div to .purchase, and it takes on those class attributes. Possibly change the declaration to div.return and the id='return' to class='return'.

Edit

Going to update this until I find the answer on why it's not working, or someone else posts. So far, I'm able to reference the div via document.getElementById('return').style.color = '#FFFFFF';

Robert
Ill switch the container for the AJAX content from #return to .return and see what happens. Any idea why ID's wont work?
Dirty Bird Design
Not a clue yet, but you've piqued my interest.
Robert
$("#return").css('color','#FFFFFF') in the "complete: function block of the AJAX call seems to do it. I guess I could write a style in the CSS and do a $("#return").hasClass('foo'). Seems like I've already got a lot in that function though and doing it in the external CSS would be cleaner?
Dirty Bird Design
Right, I was talking about changing `<div id='return'>` to `<div class='return'>` and referencing it as `.return` everywhere rather than `#return`
Robert
Understood, I appreciate your help. Ill switch from ID to Class and see where that gets me. No luck, switching it to class had no affect
Dirty Bird Design
@Robert, @yc - changing it to #foo had no affect either. Right now it looks like I have to style it with the above mentioned jQuery call. This is strange. and annoying.
Dirty Bird Design
adding a class via jQuery doesn't work either, it adds the class but none of the styles associated with the class. Ill just have to add the styles in a call. Can you add more than one CSS attribute in a jquery call at at time? $("#return").css('color','#FFFFFF', 'font','12px Arial') is incorrect
Dirty Bird Design
`$('#return').css({color: '#FFFFFF', font: '12px Arial'});`
Robert
@Robert - thanks, i guess ill have to go that route. It must have something to do with that element being created dynamically in the PHP script and returned via AJAX. your time is much appreciated!
Dirty Bird Design