javascript - Upload button will not fire programmatically -
i have button want use "upclick"-plugin uploading files
<script type="text/javascript" src="~/scripts/upclick-min.js"></script> <input type="button" id="uploader" value="upload" > <script type="text/javascript"> var uploader = document.getelementbyid('uploader'); upclick( { element: uploader, action: '/path_to/you_server_script.php', onstart: function(filename) { alert('start upload: '+filename); }, oncomplete: function(response_data) { alert(response_data); } });
now button works in , opens "open file"-dialogue, cannot seem fire "click"-event on programmatically. ive tried different ways of writing syntax-wise:
if (ui.draggable.hasclass('ui-dragdrop-picelement')) { //$("uploader").trigger("click"); //$("uploader").click(); //$('uploader').click(); //$('#uploader').click(); //$("#uploader").click(); //$("#uploader").trigger("click"); //$('button#uploader').trigger('click'); $('#uploader').trigger('click'); alert("w00t"); }
and on - idea why wont fire - alert message!
$("uploader")...
this isn't valid. there no <uploader>
element.
your last .click
uses correct selector, you'll want use .trigger()
event:
$("#uploader").trigger("click");
you'll benefit lot going through official jquery tutorial: http://try.jquery.com.
Comments
Post a Comment