What is wrong with this jquery statement.?

I’m having the following code. Everything seems to work fine but its just that some times, there are times whereby the confirm and alert notices appear multiple times and they just get overly annoying. Is there any problems with the following code. Thanks for any advice.

    $('.order_stateselect').hover(function(){
        var value_text=$(this).find(":selected").text();
        var value_code=$(this).find(":selected").val();
        $(this).change(function(){
            if(confirm('Confirm Order Status Change?')){
                var conduct_status_chge=$.post('/seller/helpers/order_status_change.php',{order_item_id:$(this).parent('td').siblings('.order_item_id').text(),order_item_status:$(this).find(':selected').val()},function(data){
                    alert(data);
                })
                .error(function() {
                    $(this).find(':selected').removeAttr('selected');
                    $(this).find('option:contains(value_code)').attr('selected','selected');
                    alert('error');

                });
            }else{
                $(this).find(':selected').removeAttr('selected');
                $(this).find('option:contains(value_code)').attr('selected','selected');
            }
        });
    });

A brief explanation of what i’m doing here.

This is a selectbox with multiple options. This selectbox is part of a table cell in a list of items.

ie: Meaning that each row contains an item and for each row, there is a a selectbox dedicated to that specific row.

1) Upon hover, i get the values of the selected option loaded via my database value when the page loads.

2) When the user selects a different value from the selectbox and confirm selection, i do a $.post.

3) If user press cancel or if there is an error with the script call that causes the the $.post to fail, i revert the selected option back to the original value from database.

I’m sorry if my explanation is abit unclear but please let me know if you guys need anymore information. thanks.

Leave a Reply

*

Hire Me
Follow Me!
Search
Most Popular Articles & Pages
Because your vote is Important
Sorry, there are no polls available at the moment.
Categories