如何在按钮点击的材料ui中打开一个对话框

时间:2016-11-04 18:51:25

标签: reactjs redux material-ui

<?php

namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Redirect;

use Illuminate\Http\Request;

use View;

use App\Model;

use App\User;

use App\Booking;

use App\BookingItem;

use App\Http\Controllers\Validator;

use Input;

class BookingsController extends Controller
{

    /**
     * Display a listing of the resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function index()
    {
        $bookings = \App\Booking::all();
        return View::make('bookings.index')->with('bookings', $bookings);
            // $user = auth()->user()->id;
            // $bookings = auth()->user()->bookings()->get();
            // return view('bookings.index')->with('bookings', $bookings);

    }

    /**
     * Show the form for creating a new resource.
     *
     * @return \Illuminate\Http\Response
     */
    public function create()
    {
        $user = auth()->user();
        return View::make('bookings.create')->with('user', $user);
    }

    /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request, $user_id)
    {
        // define rules
        $rules = [
            'name' => 'between:2,255',
        ];

         $this->validate($request, [
            'name' => 'required|unique:bookings|max:255',
        ]);


        $name = $request->get('name');
        $description = $request->get('description');
        $booking->name = $name;
        $booking->user_id = $user_id;
        $booking->description = $description;
        $booking->save();
        return Redirect::route('bookings.index')->withMessage('Booking Was Created');
    }

    /**
     * Display the specified resource.
     *
     * @param  int  $id
     * @return \Illuminate\Http\Response
     */
    public function show($id)
    {
        $booking = \App\Booking::findorFail($id);
        $items = $booking->BookingItems()->get();        
        return View::make('bookings.show')
        ->withBooking($booking) // will allow us to see our bookings, by id.
        ->withItems($items);

    }
}

?>

我打开一个使用material-ui按钮点击的对话框,现在我在控制台中看到一个错误,说无法读取属性&#39; prepareStyles&#39;未定义..我可以看到屏幕上的按钮

1 个答案:

答案 0 :(得分:0)

不确定您是否仅从您的代码段中省略了它们,但请确保在您的真实代码中您在顶部输入了正确的材料-ui:

import Dialog from 'material-ui/Dialog';
import FlatButton from 'material-ui/FlatButton';