I'm struggling to find a solution to this problem, I need to load a view from within another view. I know, usually, i would just have to do :
<?php $this->load->view("smthg");?>
But this time, the file path is passed to a data-file tag's property. I have :
<a data-file="<?php echo site_url('main/loadCocktailRecipient') ?>/{{Id}}" href="#">
and actually, this is used by a javascript function to load the view by itself. so when doing like so, It load the controller instead of the view file. (or it maybe even do not load anything) Let say I've put my view into the app/views folder. how can I make sure this script actually loads this file without the need of the controller ?
If this is not possible, how can I adapt the js script to load, not the file itself (which here, would be the controller first) but the final view returned by CI' controller ?
EDIT: JS script:
$(".cocktail .cocktail-item a").on('click', function(event) {
event.preventDefault();
var fileToLoad = $(this).data('file');
if(portfolioActive) {
closePortfolio(true, fileToLoad);
} else {
loadPortfolio(fileToLoad);
}
});
and load portfolio function is :
function loadPortfolio(fileToLoad) {
$portfolioSingle.load(fileToLoad, function() {
portfolioSingleH = $portfolioSingle.find('.container').outerHeight();
$portfolioSingle.css({
'top': -portfolioSingleH
});
$('#portfolio').animate({ scrollTop: 0 }, "slow");
$portfolioSingle.stop().animate({
'top': 0
}, 500, 'easeOutCubic');
$portfolioContainer.stop().animate({
'marginTop': portfolioSingleH
});
portfolioActive = true;
bindClosePortfolio();
bindFancybox();
setupFlexslider();
});
}
if this is too complex, then how can I simply tell him to look for a handlebar script by id and load the content that would be generated dynamically ?
Thanks