Totaljs blogengine: post in modal window

70 views Asked by At

Sorry, I speak poor English!

I am new to Totaljs and I am having a problem:

Node v12.4.0 Total.js v3.2.4 BlogEngine v2.0.0

I want to put the content of an post in a modal window on the home page, that's the goal!

Here is my code for AJAX:

var links = document.querySelectorAll('a.tinymodal-modal');
for (var i = 0; links.length > i; i++) {
    links[i].addEventListener("click", function(event){  // callback
        "use strict";
        event.preventDefault();
        var element = this.getAttribute("href");

        alert('AJAX HREF = ' + element);

            $.ajax({   
                type: 'GET',                                   
                url: '/api/blogs/',                                            
                data: element,                  
                success: function(data, textStatus,jqXHR){
                  console.info(data);
                  alert(JSON.stringify(data));
                  // Display Modal

The problem I get back all blog posts and not the selected post!

Do you have a way to solve this problem?

Thank you so much !!!

0

There are 0 answers