I am able to successfully query my database to find an existing data. But now, i don't know how to make the table only display the item being search for. When the textbox is cleared, the table should go back to it default state.
How do i achieve this please?
Controller
User.abc(params[:id], params[:email])
JS
public function index(Request $request)
{
$query = "%".$request->get('myInput')."%";
$students = Student::where('name','LIKE',$query)->where('grade_id',Auth::user()->grade_id)->paginate(5);
return view('customer.index',compact('stduent','query'));
}
答案 0 :(得分:1)
You may use export default {
head () {
return {
title: this.project.title,
meta: [
{property: 'fb:app_id', content: '12873892173892'},
{property: 'og:title', content: this.project.title},
{property: 'og:image', content: this.project.image},
],
}
}
},
async asyncData ({app, params, error}) {
const project = await app. $ axios. $ get (`/ project`)
return {
project: project.project,
}
}
}
to clear in it before appending data for new search
答案 1 :(得分:1)
You could try this:
mb_detect_encoding
since you are checking success: function (data) {
var table = $("#table tbody");
$.each(data, function(idx, elem){
table.append("
<tr><td>"+elem.id+"</td>
<td>"+elem.name+"</td>
<td>"+elem.lastname+"</td>
</tr>
");
});
}
that means if user does not input anything then leave the table with the current content. Read this