DataEmbed

DataEmbed can embed a url and then isolate it in the dom.
So you can build multiple widgets in page, and all actions will be execued without page reload
Scenarios (where you cant reload the page):
  • a form in a bootstrap modal
  • a login-form in a cached page
  • a comment widget in a static page
You have only to give the endpoint url and an id, then it will be loded and will work isolated in the dom.

Requirements are jquery, riotjs, pjax in your master layout:
    
        <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.pjax/1.9.6/jquery.pjax.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/riot/2.2.4/riot+compiler.min.js"></script>
        {!! Rapyd::scripts() !!}
        <script>riot.mount("*")</script>
        ..
      </body>    
    


class DemoController extends Controller

....

    public function 
getEmbed()
    {
        
//embed some widgets and isolate the dom using riot & pjax
        
$embed1 = \DataEmbed::source('/rapyd-demo/nudegrid''embed1')->build();

        
//if you prefer you can simply use an html tag
        
$embed2 '<dataembed id="embed2" remote="/rapyd-demo/nudeedit?modify=1"></dataembed>';
        
        return 
view('rapyd::demo.embed'compact('embed1','embed2'));
    }




class DemoController extends Controller

....

    public function 
getNudegrid()
    {
        
$grid = \DataGrid::source(Article::with('author','categories'));
        
$grid->attributes(array("class"=>"table table-striped"));
        
$grid->add('id','ID'true)->style("width:70px");
        
$grid->add('title','Title'true);
        
$grid->edit('/rapyd-demo/nudeedit''Edit','modify|delete');
        
$grid->paginate(10);
        return 
$grid;
    }




class DemoController extends Controller

....

    public function 
anyNudeedit()
    {
        if (\
Input::get('do_delete')==1) return  "not the first";

        
$edit = \DataEdit::source(new Article());
        
$edit->link("rapyd-demo/nudegrid","Articles""TR");
        
$edit->label('Edit Article');
        
$edit->add('title','Title''text')->rule('required|min:5');
        
$edit->add('public','Public','checkbox');
        return 
$edit->view();
    }



@extends('rapyd::demo.demo')

@section('title','DataEmbed')

@section('body')

    

    
    <h1>DataEmbed</h1>

    DataEmbed can embed a url and then isolate it in the dom.<br />
    So you can build multiple widgets in page, and all actions will be execued without page reload<br />  
    
    Scenarios (where you cant reload the page): 
    <ul>
        <li>a form in a bootstrap modal</li>
        <li>a login-form in a cached page</li>
        <li>a comment widget in a static page</li>
    </ul>
    You have only to give the endpoint url and an id, then it will be loded and will work isolated in the dom.<br />
    <br />

    <div class="container">
        <div class="row">
            <div class="col-sm-6">
                
                {!! $embed1 !!}
            </div>

            <div class="col-sm-6">

                {!! $embed2 !!}
            </div>
        </div>
    </div>

    Requirements are jquery, riotjs, pjax in your master layout:
    <pre>
    <code>
        <?php echo htmlentities('<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.pjax/1.9.6/jquery.pjax.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/riot/2.2.4/riot+compiler.min.js"></script>
        {!! Rapyd::scripts() !!}
        <script>riot.mount("*")</script>
        ..
      </body>'
);?>
    </code>
    </pre>

    
    
    
    

@stop

Whoops, looks like something went wrong.