【发布时间】:2018-02-16 05:57:02
【问题描述】:
我正在尝试让内联编辑弹出窗口 x-editable 在我的 Laravel 应用程序中工作。我有一个精简的测试用例来让它发挥作用,但无法从中得到响应。该页面看起来不错,是来自数据库的链接名称列表,但它们没有响应。
我安装了 x-editable 引导库,并且可以在控制台中看到它们已找到并且正常。我没有从链接中得到任何响应(它应该弹出和编辑框)。没有错误,一切看起来都很好,但有些东西坏了。有什么想法吗?
控制器:
<?php
namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\Request;
use App\investment_account;
use App\investment_line_item;
class popupEditController extends Controller
{
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('auth');
}
/**
* Show the application dashboard.
*
* @return \Illuminate\Http\Response
*/
public function index()
{
$investment_item = investment_account::find(1)->investment_line_item;
$investment_line_items = investment_line_item::all();
return view('popupEdit', compact('investment_item','investment_line_items'));
}
public function updatePosition(Request $request)
{
}
}
路线(web.php):
Route::get('/popupEdit', 'popupEditController@index');
Route::post('/popupEdit', 'popupEditController@updatePosition');
刀片:
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet">
<script src="http://code.jquery.com/jquery-2.0.3.min.js"></script>
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="bootstrap-editable/css/bootstrap-editable.css" rel="stylesheet">
<script src="bootstrap-editable/js/bootstrap-editable.js"></script>
<meta name="csrf-token" content="{{ csrf_token() }}" />
<script type="text/javascript">
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
</script>
@foreach ($investment_line_items as $single_item)
<a href="#" id="investmentName" data-type="text" data-pk="{{ $single_item->id }}" data-title="Edit investment">{!! $single_item->investment_name !!}</a></br>
@endforeach
<script>
$(document).ready(function() {
$.fn.editable.defaults.mode = 'popup';
$.fn.editable.defaults.send = "always";
$.fn.editable.defaults.params = function (params)
{
params._token = $("#_token").data("token");
return params;
};
$('#investmentName').editable({
type: 'text',
url: '/',
send: 'always'
});
});
</script>
我正在 XAMPP 上使用 Laravel 5.5 和 PHP7。感谢您的任何建议。
【问题讨论】:
标签: php laravel x-editable