Note that there are some explanatory texts on larger screens.

plurals
  1. POAngularjs: Directive addEventListener Error
    primarykey
    data
    text
    <p>I have created a directive to handle a file upload wit <a href="http://www.uploadify.com/download/download-uploadifive-standard/" rel="nofollow">Uploadifive</a>. The upload module is called on the opening of a modal window. The first time that I call the modal window everything works correctly. If I open the modal window again I receive the following error.</p> <pre><code>Cannot call method 'addEventListener' of undefined </code></pre> <p>I am new to this so if I don't have enough information to trouble shoot this just let me know what else is needed. </p> <p><strong>HTML</strong></p> <pre><code>&lt;div class="row"&gt; &lt;div class="span5"&gt; &lt;h2&gt;Upload New Image Gallery&lt;/h2&gt; &lt;form name="frm_upload" action=""&gt; &lt;div class="control-group"&gt; &lt;input image-uploadifive="{{galleryID}}" galleryid="{{galleryID}}" name="file_upload" type="file" multiple="true"&gt; &lt;/div&gt;&lt;!-- /control-group --&gt; &lt;/form&gt; &lt;div id="imageGallery_queue"&gt;&lt;/div&gt; &lt;/div&gt;&lt;!-- /span5 --&gt; </code></pre> <p></p> <p><strong>Directive</strong></p> <pre><code> myApp.directive('imageUploadifive', function () { return { restrict: 'A', link: function(scope, element, attrs, controllers) { var id = scope.galleryID; $(element).uploadifive({ 'uploadScript' : '/beta/images/upload', 'buttonClass' : 'uploadifive-button btn btn-primary', 'queueID' : 'imageGallery_queue', 'buttonText' : 'Select Files', 'fileSizeLimit' : 500, 'formData' : { 'galleryID' : id }, 'onError': function(errorType) { alert('There was a problem'); }, 'onUpload': function() { } }); } }; }); </code></pre> <p><strong>Controller</strong></p> <pre><code>var myApp = angular.module('myApp',['ui.bootstrap', 'ui.sortable']); </code></pre> <p>function imageGalleryCtrl ($scope, images, clients, galleries, createGal) { $scope.galleryMaster = {};</p> <pre><code>$scope.tabs = [ { title:"Home", content:"/beta/application/views/images/uploader/create.html", active: true }, { title:"Upload", content:"/beta/application/views/images/uploader/upload.html"}, { title:"Edit", content:"/beta/application/views/images/uploader/edit.html"} ]; //close modal $scope.close = function () { $scope.imageUploader = false; }; //get gallery info on click from table $scope.getGallery = function(id) { //set gallery ID to scope $scope.galleryID = id; //open the modal $scope.imageUploader = true; //get gallery information $scope.galleryCollection = galleries.getGallery(id); $scope.galleryCollection.then(function(galleries){ $scope.gallery = galleries.thisGal; }); //get clients $scope.clientCollection = clients.getClients(); $scope.clientCollection.then(function(clients){ $scope.clients = clients.clients; $scope.clientList = $scope.gallery.client; }); }; $scope.tabName = function(name) { if(name == 'Edit'){ //get all the images $scope.imgCollection = images.getImages($scope.galleryID); $scope.imgCollection.then(function(images){ $scope.images = images.thisGal_images; $scope.imageSortOrder = 'orgName'; }); } }; $scope.newGallery = function() { //open modal $scope.imageUploader = true; //create gallery $scope.newGallery = createGal.createGal(); $scope.newGallery.then(function(createGal){ $scope.galleryID = createGal.created_id; }); }; </code></pre> <p>Any insight on this would be a great help. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload