Need to call the Action inside the function

I’m doing the action for while click on the download icon in the folder type. It have to download as zip. For that they wrote already in the java and created a service for that as like below:

Core.Action({
    id: 'core:downloadZip',
    invoke: function (context) {
        console.log(context);
        var mos = Ember.get(context, 'managedObjects') || [Ember.get(context, 'managedObject')];

    var moIdResult = [];
    var moArray ='';
    mos.forEach(function (mo) {
        moArray = moIdResult.push(mo.get('finalManagedObject.id'));
      });
      Core.services({
        download:true,
          type: 'get',
          service: 'content/zip',
          iframe: true,
          data: {
            coreId: moIdResult
          }
      }).done(function (response) {
          console.log(response);
      }.bind(this));
  },isValid: rules.all(
          rules.any(rules.isMO, rules.areMOs),
          rules.not(rules.isHome)
      )
});

In that service: ‘content/zip’ doing that action as download as zip from the java file. But when I’m calling the above code in the same file as like below:

click: function(e) {
                  var type = this.get('content.kind');
                  if(type == 'Folder'){
                      Core.Action('core:downloadZip', context);
                  }
           }

When I’m calling as like above, its not taking and moreover not even showing any error in console. Can anybody please provide me suggestion on this. I’m new to the Ember and I’m using ember 1.4.0 version. Thanks in advance

Hi @boo, to debug what’s going on, I suggest putting a breakpoint into your click function, firstly just to see if it’s running at all, and secondly if it is running to check what type you are getting from your content.kind.

If your click is not running, please share more detail about which file it appears in, and what the corresponding template says.

1 Like