추가 버튼을 추가하지 않고 업로드 스크립트를 다시 시작하려면 어떻게해야합니까?
문제
나는 여기에서 과정을 통해 당신을 걷고 있습니다.
1 단계
1. DropdownList에서 제품을 선택하십시오
2. 양식에는 데이터가 채워집니다
3. 숨겨진 ID는 선택한 항목의 제품 ID입니다.
4. 업로드가 초기화되고 제품 ID를 검색합니다. 업로드 버튼이 추가됩니다.
2 단계
1. DropdownList에서 신제품을 선택하십시오
2. 양식에는 데이터가 다시 채워집니다
3. 숨겨진 ID는 선택한 항목에서 새로운 제품 ID입니다.
4. 업로드가 초기화되고 제품 ID를 검색합니다. 새로운 업로드 버튼이 추가되었습니다.
이제 두 개의 버튼이 붙어 있습니다. 내가 원하는 것이 아닙니다.
버튼이 추가되어 버튼을 다시 시작하지 않는지 확인할 수 있지만 업로드 스크립트는 신제품 ID (기타에 필요한 경우)를 검색하지 않습니다.
이 작은 문제를 어떻게 해결할 수 있는지 아이디어가 있습니까?
이것은 내 업로드 기능입니다.
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();
제휴하지 않습니다 StackOverflow