How to call the triggerHandler
method for dynamically added nodes in Angular?
My nodes are dynamically generated based on a table:
<a class="btn btn-default J_Local" href="javascript:void(0);" id="J_MapImg_{{my.sku_val_id}}" ng-click="uplod($event)"><span>本地上传</span></a>
The click event is as follows:
$scope.uplod = function(obj){
supload.init({
button: ''+obj.currentTarget.id+'', uploaded: function (uploader, file, response) {
if (response.code == 1){
layer.msg(response.msg);
}
else {
$('#'+obj.currentTarget.id).siblings("p.preview").html("<img src='" + response.src + "' width='20' height='20'/>");
}
}
});
$('#'+obj.currentTarget.id+'').off("click");
}
But the dynamically generated image calls my image upload and requires double-clicking to be punished. I want to have it automatically trigger a click when a click is generated. How to achieve this?
If it is
angularjs
, it is wrong to mix jQuery in itFor your scenario, there is no need to dynamically insert html code, and master the following knowledge points
If it is jquery, you need to use the $().on("click",function(){}) form