im beginner in laravel/ajax, and trying to declare object.name inside the html class objectbutton, and if its clicked, to pass object.name to another function that will show object.name in the content-area div.
$(document).on('click', '.block-button', function(){
// access current block instance by listening to touched class
var block_id = $(this).attr('block-id');
$.ajax({
// laravel route access
url: '{{ route("content:page") }}',
type: 'get',
data: {input_block: block_id},
beforeSend:function(){
//in jquery . for class and # for ID
//LOADING TEXT
$('#content-area').html('Loading........')
},
success: function(result){
$('#content-area').css('background-color', result.color);
var blockInfos = '<h3>'+result.name+'</h3><h3>'+result.content+'</h3>';
//Loop over objects if exist
var objectsInfos = '';
if (result.objects.length > 0) {
//Loop
$.each( result.objects, function( index, object ){
objectsInfos = objectsInfos + '<div><a href="" class="object-button" id="'+ +object.name+ '">'+object.name+'</a></div>';
});
}
$('#content-area').html(blockInfos + objectsInfos);
}
});});
as you can see on the code im tryign to pass object.name inside the id of the html, is there any way to place object.name inside the html link so i can retrieve it with another onclick function, how this would work? im not sure if this is possible to do in this way with html. Thank you!