dimanche 4 mars 2018

in laravel is it possible to use cropit with ajax when i have two blade templates and both use ajax and cropit to read and save the image

in laravel i have two blade templates, and i read and show them using ajax , in this two bootstraps ( wich is showing my blade template ) , i have cropit plugin , its a js plugin to crop images and save them , however , i can not enclude both of my templates , one is overriding the other , for example when @include('addstudent.blade.template') is first , i can save the image using that , but i can't save the image with @include('editstudent.blade.template') i even changed the name of the forms , but no success ! i can only include one of my blade templates , is there any solution so i can use them both ? ( remember i'm using ajax ) . here is the code for addstudent : from $('#cropitbaby').on('submit',function (e) to e.preventDefault(); , is the important part , the rest is not relevant to my question .

    $('#frm-insert').on('submit',function (e) {

        $('#cropitbaby').on('submit',function (e) {
            e.preventDefault();
        });
        $('#cropitbaby').submit();
        var passdata = $("input#image-data").val();
        $("input#usercropedimage").val(passdata);
        var data = $(this).serialize();
        var url = $(this).attr('action');
        var post = $(this).attr('method');
        e.preventDefault();
        $.ajax({
            type:post,
            url:url,
            data:data,
            dataty:'json',
            success:function (data) {
                var tr = $('<tr/>',{
                    id : data.id
                });
                tr.append($('<td/>',{
                    text:data.id
                })).append($('<td/>',{
                    text:data.cell_phone
                })).append($('<td/>',{
                    text:data.email
                })).append($('<td/>',{
                    text:data.created_at_shamsi
                })).append($('<td/>',{
                    text:data.gender
                })).append($('<td/>',{
                    text:data.username
                })).append($('<td/>',{
                    text:data.family
                })).append($('<td/>',{
                    text:data.name
                })).append($('<td/>',{


                    html : '<a href="#" class="btn btn-info btn-sm" id="view" data-id="' + data.id + '">تغییر رمز</a> '
                    + '<a href="#" class="btn btn-success btn-sm" id="edit" data-id="' + data.id + '">ویرایش</a> ' +
                    '<a href="#" class="btn btn-danger btn-sm" id="del" data-id="' + data.id + '">حذف</a>'
                }));


                $("input#image-data").cropit('destroy');
                $('#student-info').append(tr);
            }
        })
    })

the code for update is the same . but that is not the problem . the problem is why one of them is overriding another , for example if i use and include addstudent.blade.php i would not be able to use update ( i mean the part that relates to reading and saving the image with cropit ) . it would get its data from addstudent.blade.php !!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2CYgfVX
via IFTTT

Aucun commentaire:

Enregistrer un commentaire