Apending data to url not rendering correctlu

Apending data to url not rendering correctlu

InnocentmInnocentm Posts: 11Questions: 3Answers: 0

I am trying to append data to my url in datatables but it does not seem to render correctly, the data am appending is a url to a file. Is there anything am not doing right?

Here is my code

 $(document).ready(function(){
        $('#invoice-table').DataTable({
        processing: true,
        destroy:true,
        ajax:'{!! url('account/allinvoices') !!}',
        columns: [
            {data: 'order_number', name: 'order_number'},
            {data: "invoice_number",render: function ( data, type, row ) {
                    if (data !='') {
                        return '<a href="{{asset('+data+')}}">View Invoice</a>';
                        }
                        else{
                            return data;
                    }
                }
            },
            {data: 'action', name: 'action', orderable: false, searchable: false}    
            ]
        });
});

When the link is clicked it simply displays the string +data+ in the address bar instead of the required url

Answers

  • kthorngrenkthorngren Posts: 21,444Questions: 26Answers: 4,974

    You probably want to let Javascript build the URL instead of your templating engine. Try this:

    return '<a href="'+data+'">View Invoice</a>';
    

    Kevin

This discussion has been closed.