It's a bit hard to get the full blade template url.
This another solution : listen for the button click or your event and then :
$('.container').html("@include('layout/partials/_filter')");
How I could get the partial balde url to call in a function. I need put the partial view in public folder?
This is my code
$.get(' {{ @include('layout/partials/_filter') }} ', function(template) {
$('.container').html(template);
},"text");
It's a bit hard to get the full blade template url.
This another solution : listen for the button click or your event and then :
$('.container').html("@include('layout/partials/_filter')");
?!!! You just want to display / hide a part of your html ? Why using an ajax call ?
Make a route that renders that partial and have that in your ajax call
That is not a good approach. Just render the partial and show/hide it.
take a look AngularJS ng-if, ng-show and ng-hide. Blade is no good for DOM manipulation. It is ok for one time render as it doing a <?php > code execution, but if you are looking for conditional post render then JavaScript is the way to go.
<div ng-if="channel.counter > 0" class="mme-channel-console">
<div class="channel-action">
<div class="channel-action-btn level">
<span>{[{ channel.counter }]}</span>
</div>
</div>
</div>
<div class="form bg-blue space clearfix ng-cloak" ng-cloak ng-show="setMiniControl['add']">
// .. content
</div>
Also, Angular has a ton of conditional DOM directives, ajax, etc. It was designed for the very thing of loading partials based on any JS condition. You can also use ng-model and filter to filter content in a ng-repeat as example or can build your own filters for just about anything. You can build you own directives example
No with all of that said you can get AJAX to return a string that you can then use to wrap around a placeholder object
endMoving = function(e){
e.preventDefault();
var url = "http://localhost:8888/imageaction/";
$.ajax({
type: "GET",
url: url,
data: {
_token: token
}}).done(function(newHtml) {
$('#placeholder').html(newHtml )
});
};
Laravel - have no tested pass html string back
public function getHtml()
{
/// or however you get the html
$html = "<div>this is a test</div>";
return return response($html, 200);
}
Or you could simple surround the partial with an if statement. Use the controller to determine if it should be visible, and pass a boolean variable (or function) to put on that if statement.
Sorry with the delay
y have a template in mustache in one file "list.html" Whit ajax I call a json and recall the list whit the content I change dinamic param with a onclick action and I need to charge the template
$( ".reload" ).click(function() {
var filter = $(this).attr("slug");
$.get('/filter.blade.php', function(template) {
$('.container').html(template);
},"text");
$.ajax({
//get the subdomain dinamic
url: "http://jsonUrl/dinamicParam",
dataType: 'json',
success: function(data) {
var list = Mustache.to_html($('#list').html(), data); //#list is under container in the file list.html
$('.container').html(list);
}
});
}
I need some type to render to URL view. I hope I explained well
Please or to participate in this conversation.