开发者

IE form element (checkbox) problem. Have tried several things

开发者 https://www.devze.com 2023-03-25 04:55 出处:网络
Here\'s the deal.I have built a site to market lumber handling products our company sells, and it works great in Firefox, Chrome, etc.In IE (7, 8 and 9), rendering is fine, but there is one peculiar i

Here's the deal. I have built a site to market lumber handling products our company sells, and it works great in Firefox, Chrome, etc. In IE (7, 8 and 9), rendering is fine, but there is one peculiar issue with our quote form.

When a user is browsing the site and they see something they like, they can hit "add to quote request" and it will add it to the quote request in their current session. If they want to review or finish their request, they have the things they were interested in preselected.开发者_如何学运维 Here is a screencast showing intended behavior:

http://screencast.com/t/YPSbWjVe

I'm requesting http://lumberhandling.com/quote via jquery $.get to grab the form.

Here is a screencast of the same activity in IE9:

http://screencast.com/t/3jRHSLUjC

I do exactly the same thing, but if I click the quote request button and the modal is activated, I am "stuck" with whatever was checked in the modal the first time. I cannot update the modal content until I actually type the quote url in my address bar and go to the fallback page http://lumberhandling.com/quote

I've even tried forcing a check to ensure that items which are selected (these are stored in db sessions) get selected:

function checkQuoteItems()
{
    $(document).bind('cbox_complete', function() 
    {
        $.getJSON("/quote/check_quote_items", function(json) {
            $(json.items).each(function(index, value)
            {
                var solution = 'solution_'+value;
                $('.checkbox[name="'+solution+'"]').attr('checked', 'checked');
            });
        });
    });
}

Sadly, no dice in IE. Can anyone point me in the right direction on debugging this? I am kind of bewildered.


I figured out my issue. The problem was that the URL of the form was getting cached in IE. I used an ajax request with cache set to false in order to resolve.

function checkQuoteItems()
{
    $(document).bind('cbox_complete', function() 
    {
        $.ajax({
              url: "/quote/check_quote_items/string",
              cache: false,
              type: "GET",
              dataType: "json",
              success: function(json){
                    if(json.items != null)
                    {
                        $(json.items).each(function(index, value)
                        {
                            trace(value);
                            $('.checkbox[name="solution_'+value+'"]').attr('checked', true);
                        });
                    }      
              }
          });

    });
}


I hope checkbox is a classname applied to the checkbox elements. You can try this

function checkQuoteItems()
{
    $(document).bind('cbox_complete', function() 
    {
        $.getJSON("/quote/check_quote_items", function(json) {
            $(json.items).each(function(index, value)
            {
                $('.checkbox[name=solution_"'+value+'"]').attr('checked', true);
            });
        });
    });
}
0

精彩评论

暂无评论...
验证码 换一张
取 消