缓存对象失去了它的值后,页面离开,我试图回来



环境:我使用isml作为视图(需求模板),浏览器是chrome。

我正在尝试的是存储商店ID:

function cacheStores(data) {
        cachedStores = {};
        for (var i = data.length - 1; i >= 0; i--) {
            var store = data[i];
            console.log(store);
            cachedStores[store.physicalId] = store;
        }

当我在页面上时它工作,但是当我离开页面(到下一页)并试图返回它时,值为空。

ISML:

<input type="hidden" name="dwfrm_billing_shippingAddress_addressFields_houseNumber" value=>

即函数设置名称和值

    function setShippingField(name, value) {
        jQuery('input[name=' + name + ']', addressContainer).val(value);
    }
    //only set if housenumber is a field
    if ($houseNumber.length) {
        var matches = shippingAddress1.match(/d+/);
        if (matches) {
            shippingHouseNum = matches[0];
            shippingAddress1 = shippingAddress1.replace(shippingHouseNum, '');
            setShippingField(checkout.initFields.s_houseNumber, shippingHouseNum);
        }
    }
        // set hidden fields
        setShippingField(checkout.initFields.s_title,     billingTitle);
        setShippingField(checkout.initFields.s_lastName,  shippingLastName);
        setShippingField(checkout.initFields.s_firstName, shippingFirstName);
        setShippingField(checkout.initFields.s_address1,  shippingAddress1.substr(0, MAX_ADDRESS1_LEN));
        setShippingField(checkout.initFields.s_address2,  shippingAddress2);
        setShippingField(checkout.initFields.s_address3,  store.physicalId);
        setShippingField(checkout.initFields.s_zip,       store.address.postalCode);
        setShippingField(checkout.initFields.s_city,      shippingCity);
        setShippingField(checkout.initFields.s_country,   billingCountry);
        // set visible labels
        jQuery('#customer', addressContainer).text(billingTitle + " " + shippingAddress2);
        jQuery('#shopname', addressContainer).text(shippingLastName + ' ' + shippingFirstName);
        jQuery('#shopstreet', addressContainer).text(shippingAddress1 + ' ' + shippingHouseNum); // includes house number
        jQuery('#shopid', addressContainer).text(store.physicalId); // we're not using shop ids here
        jQuery('#shopzipcity', addressContainer).text(store.address.postalCode + ' ' + shippingCity);

        window.top.close();
    }

它看起来像客户端问题,你有一个。我不认为这与您正在使用的服务器端逻辑有关。

setShippingField(checkout.initFields.s_address3,  store.physicalId);

不应该用不同于s_address3字段作为键吗?

从你的代码片段中,你不清楚在checkout变量和它的initFields成员中究竟有什么。还有,你传递给cacheStores函数的data参数到底是什么?

顺便说一下,对不同作用域的不同事物使用相同的标识符是不好的做法(cacheStores在一个作用域是函数,而在另一个作用域是对象)

相关内容

  • 没有找到相关文章

最新更新