开发者

Seems that IE8 hates JavaScript switch

开发者 https://www.devze.com 2023-03-18 23:31 出处:网络
Do you see anything wrong in this switch statement. IE8 executes step 3 twice. That\'s the problem. function controlLoader(step) {

Do you see anything wrong in this switch statement. IE8 executes step 3 twice. That's the problem.

function controlLoader(step) {
    switch (step) {
        case 1:
            $.rayanAjax('/NewSitePurchaseWizard.aspx/GetSiteTitle', null, function (result) {
                $('#contents-holder').html(result);
            }, null, $('#wizardWrapper'));
            break;
        case 2:
            $.rayanAjax('/NewSitePurchaseWizard.aspx/GetTemplates', null, function (result) {
                $('#contents-holder').html(result);
            }, null, $('#wizardWrapper'));
            break;
        case 3:
            $.rayanAjax('/NewSitePurchaseWizard.aspx/GetSubDomain', null, function (result) {
                $('#contents-holder').html(result);
            }, null, $('#wizardWrapper'));
            break;
        case 4:
            $.rayanAjax('/NewSitePurchaseWizard.aspx/GetLogin', null, function (result) {
  开发者_开发问答              if (result.substr(0, 8) == 'userName') {
                    $('#userName').val(result.substr(9));
                } else {
                    $('#contents-holder').html(result);
                }
            }, null, $('#wizardWrapper'));
            break;
        case 5:
            var data = { userName: '', templateName: '', lookName: '', subDomain: '', siteTitle: '' };
            data.userName = $('#userName').val();
            data.templateName = $('#templateName').val();
            data.lookName = $('#lookName').val();
            data.subDomain = $('#subdomain').val();
            data.siteTitle = $('#siteTitle').val();
            $.rayanAjax('/NewSitePurchaseWizard.aspx/CreateSite', data, function (result) {
                $('#contents-holder').html(result);
            }, function (error) {
                alert(error.Message);
            }, $('#wizardWrapper'));
            break;
    }
}

update:

My scenario is that, I have a wizard with 5 steps and on each step, when user interacts with the step, (s)he clicks next button. On click of next button, I validate step and if it's valid, I simply call this function, passing the index of the next step. On the load of next step, I simply replace the HTML of the wizard's content with the HTML sent from server. Everything (all steps) work fine, but the step 3. I removed everything from step 3 (created a blank step), but case 3 still gets executed twice. adjustStep() function simply sets the height of the current wizard (nothing more).

0

精彩评论

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