Skip to content

Instantly share code, notes, and snippets.

@cowboyd
Forked from taras/showing-progress.hbs
Last active June 19, 2016 17:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cowboyd/c2fe7ce773c0a41c8955097fc0603e68 to your computer and use it in GitHub Desktop.
Save cowboyd/c2fe7ce773c0a41c8955097fc0603e68 to your computer and use it in GitHub Desktop.
{{#with (async (ajax)) as |result|}}
{{#loading-overlay result.isPending}}
<button onclick={{action ajax.get '/products'}}>Load</button>
{{#with (list result) as |products|}}
{{#each (list products) as |item}}
{{item.title}}
<button {{action (action ajax.delete 'products/:id'
data=(hash id=item.id)
on-success=(action products.remove item))
on-error=(action notifications.error 'Could not delete item')
}}>Delete</button>
{{/each}}
{{/with}}
{{/loading-overlay}}
{{/with}}
{{#with (ajax) as |ajax|}}
{{#with (async ajax on-init=(action ajax.get '/products'))) as |result|}}
{{#loading-overlay result.isPending}}
{{#with (list result) as |products|}}
{{#each (list products) as |item}}
{{item.title}}
<button {{action (action ajax.delete 'products/:id'
data=(hash id=item.id)
on-success=(action products.remove item))
on-error=(action notifications.error 'Could not delete item')
}}>Delete</button>
{{/each}}
{{/with}}
{{/loading-overlay}}
{{/with}}
{{/with}}
{{#with (ajax) as |ajax|}}
{{#with (async ajax (action ajax.get '/products'))) as |result|}}
{{#loading-overlay result.isPending}}
{{#with (list result) as |products|}}
{{#each (list products) as |item}}
{{item.title}}
<button {{action (action ajax.delete 'products/:id'
data=(hash id=item.id)
on-success=(action products.remove item))
on-error=(action notifications.error 'Could not delete item')
}}>Delete</button>
{{/each}}
{{/with}}
{{/loading-overlay}}
{{/with}}
{{/with}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment