0

When I use the submit() event of blueimp file uploader within the DOM, everything seems to work fine. i.e.:

<span class="btn" ng-click="submit()">Go</span>

However, calling $scope.submit() doesn't seem to work:

<span class="btn" ng-click="customSubmit()">Go</span>

 

$scope.customSubmit = function(){
  $scope.doSOmthingElses();
  $scope.submit();
}

$scope.submit() practically does nothing when called from the js rather than from the DOM.

5
  • Are you using the Angular bindings? What does the rest of your controller code look like? Commented Oct 1, 2013 at 14:31
  • I do, I managed to hack my way around this by setting a scope variable to true each time the fileuploadsubmit event occurs, calling both my function and the blueimp function from the ng-click event, but returning from my custom function on the first line in case my scope variable indicates that the blueimp event has already occured. Now it would be very nice to be able to access the server response data somehow. Commented Oct 1, 2013 at 14:38
  • You shouldn't have to hack anything if you're using the bindings properly. Again, share the rest of your controller code... Commented Oct 1, 2013 at 14:46
  • Do you need anything else in particular in order to help me with this problem? Commented Oct 1, 2013 at 15:33
  • Looking at the source code for the Angular bindings it looks like you'll want to use one of the supplied Directives and/or the Provider. You haven't included any of your controller code, so I can't say whether or not you're doing things appropriately. Maybe BlueImp's Angular example will be of some use to you. Commented Oct 1, 2013 at 16:00

1 Answer 1

3

Try this , hope work for you

Controller.js

  app.module('app',[])
    .controller('appCtrl',function($scope){

    $scope.customSubmit = function(){
      $scope.doSOmthingElses();
      $scope.submit();
    }
    })

html

<html ng-app="app">
<body>
<div ng-controller="appCtrl">
  <span class="btn" ng-click="customSubmit()"></span>
</div>
</body>
</html>
Sign up to request clarification or add additional context in comments.

3 Comments

Thank you for your answer, but my function was already at the same scope as the submit and as the file upload plugin instance.
Oh so you want to upload file with data on submit ...Try this directive github.com/danialfarid/angular-file-upload
Which one? I ended up with <input type="button" data-ng-click="submit();doSomethingElses()"> And checking a flag which truns to true on file select on the second function before executing it

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.