I'm walking you through a processs here:
Step 1
1. Select product from dropdownlist
2. A form is populated with data
3. An hidden ID get's the product ID from the selected item
4. Uploadify is initialized and retrieves the product ID. An uploadbutton is added to form.
Step 2
1. Select new product from dropdownlist
2. The form is re-populated with data
3. The hidden ID get's the new product ID from the selected item
4. Uploadify is initialized and retrieves the product ID. A new uploadbutton is added to form.
Now I'm stuck with two buttons. Not exactly what I want.
I could check to see if the button is added and thus not re-initialize the button, but then the Uploadify script will not retrieve the new product ID (which I need for misc. stuff).
Any ideas how I could solve this little issue?
This is my uploadify function:
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);
}
});
}
}