Hedge
Hedge

Reputation: 16748

Initiate download and execute action?

I've got a link which is supposed to execute an action and initiate a download. However as soon as an {{action}} ist set the hrefattribute is suppressed.

<a {{bind-attr href=download.filepath}} {{ action "incDownload"  }}>
    {{ download.name }}
</a>

How can I make this work?

Upvotes: 0

Views: 196

Answers (1)

Oren Hizkiya
Oren Hizkiya

Reputation: 4434

Pass the filepath as a parameter to the action instead and initiate the download in the action.

<a {{ action "incDownload" download.filepath }}>
    {{ download.name }}
</a>

and then your action will have access to the filepath:

incDownload: function(filepath){
   // do stuff

   // peform the download
   window.location = filepath;
}

Upvotes: 2

Related Questions