2017-12-17 6 views
1

내 laravel 응용 프로그램에서 단추를 삭제하는 작업이 있습니다.Laravel의 내 삭제 버튼에서 자바 스크립트 마사지를 개발하는 방법은 무엇입니까?

public function deleteOneProjectTask($projectId, $taskId) { DB::table('tasks') ->where('project_id', $projectId) ->where('id', $taskId) ->delete(); return redirect()->route('projects.show')->with('info', 'Task deleted successfully'); } 

및 작업

경로을 삭제 내 블레이드 파일
삭제 버튼,

<a href="/projects/{{ $project->id }}/tasks/{{ $task->id }}/delete" class="editInline"><i class="glyphicon glyphicon-trash"></i></a> 

TaskController 삭제 방법이다

Route::delete('projects/{projects}/tasks/{tasks}/delete', [ 
    'uses' => '\App\Http\Controllers\[email protected]', 
]); 

지금은 삭제 버튼을 클릭 할 때 작업을 삭제하기 전에 확인 알림 메시지가 필요합니다. 어떻게 개발할 수 있습니까?

답변

5

단순 앵커 태그에 onclick 이벤트를 추가하십시오.

<a href="/projects/{{ $project->id }}/tasks/{{ $task->id }}/delete" class="editInline" onclick="return confirm('Are you sure to want to delete this record?')"><i class="glyphicon glyphicon-trash"></i></a> 

예 : ok

<a href="/projects/{{ $project->id }}/tasks/{{ $task->id }}/delete" class="editInline" onclick="return confirm('Are you sure to want to delete this record?')">DELETE</a>

하면 사용자의 클릭 만하여 href 작업이 실행됩니다.

+0

괜찮습니다. – John

+0

예. 작동 중입니다 ... – John