Files
money/ui/resources/views/currencies/list.blade.php
2021-03-18 23:25:35 -03:00

41 lines
929 B
PHP

@extends('layout.base')
@section('page_content')
<h2 class="ui header">
Monedas
</h2>
<div class="ui link list" id="currencies">
</div>
@endsection
@push('scripts')
<script type="text/javascript">
let currencies = {
id: '#currencies',
items: [],
setup: function() {
this.load().then((data) => {
this.build(data)
})
},
load: function() {
let url = '{{$urls->api}}/currencies'
return $.getJSON(url, (data) => {
this.items = data.currencies
})
},
build: function() {
$(this.id).html('')
$.each(this.items, (i, el) => {
let item = $('<a></a>').attr('class', 'item').attr('href', '{{$urls->base}}/currency/' + el.id)
.html(el.name)
$(this.id).append(item)
})
}
}
$(document).ready(() => {
currencies.setup()
})
</script>
@endpush