我走你通过一个PROCESSS这里:

<强>步骤1 结果 1.从下拉列表中选择搜索产品 2.一种形式中填充数据,点击 3.隐藏标识GET是从选定项目结果的产品ID 4. Uploadify被初始化,并检索产品ID。一个uploadbutton被加入以形成

<强>第2步结果 1.从下拉列表:新产品 2.形式被重新填充有数据,点击 3.隐藏标识GET是从选定项目点击新的产品ID 4. Uploadify被初始化,并检索产品ID。一个新的uploadbutton被加入以形成

现在我只能坚持两个按钮。不正是我想要的。

我可以检查以查看是否已添加的按钮,因此不重新初始化按钮,但随后的Uploadify脚本将不会检索新的产品ID(我需要杂项。东西)。

任何想法我怎么能解决这个问题不大?

这是我的uploadify功能:

function initUploadify()
{ 
    // If button is already added, do not add it again.
    // But this will not retrieve new productID.
    if( jQuery('#brand_btnBrowseLogoQueue').length < 1)
    {
        jQuery('#txtBoxFileName').css({'position':'relative', 'top':'-9px'});
        jQuery("#brand_btnBrowseLogo").uploadify({
            'uploader'       : 'wp-content/plugins/uploadify/uploadify.swf',
            'script'         : 'wp-content/plugins/uploadify/uploadify.php',
            'folder'         : 'brand',
            'fileExt'        : '*.jpg;*.jpeg;*.png',
            'auto'           : true,
            'multi'          : false,
            'method'         : 'POST',
            'height'         : '30',
            'width'          : '100',
            'buttonImg'      : 'path/to/img/btn_browse_101x30px.png',
            'scriptData'     : {'productID':jQuery("#productID").val()},
            onComplete       : function(event, queueID, fileObj, response, data) { 
                //This makes the json response readable                
                data = eval("(" + response + ")");
                //Update logo image
                setLogo(jQuery("#brandID").val(),data.fileName);
            }
        });
    }    
}
有帮助吗?

解决方案

如果你只需要改变productID这应该根据插件文档做到这一点。

//initialize uploadify when first product is selected
if( jQuery('#brand_btnBrowseLogoQueue').length < 1) {
   ...
} else {
    //uploadify already initialized just change the productId
    $("#brand_btnBrowseLogo").uploadifySettings(
        'scriptData',
        {'productID': jQuery("#productID").val()}
    );
}

其他提示

你有没有尝试创建一个新的前删除以前的按钮?

if($('#brand_btnBrowseLogoQueue').length != 0)
    $('#brand_btnBrowseLogoQueue').remove();
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top