I am trying to make notifications about the addition of goods to bookmarks and comparison with images and other buns. What is the problem - everything works for me, but I don’t like that the html-code of the popup window is in the header, I would like to put it into the template/product/compare file with a separate div with id , but I can’t figure out how to do it .

Here is the common js code for compare:

 var compare = { 'add': function(product_id) { $.ajax({ url: 'index.php?route=product/compare/add', type: 'post', data: 'product_id=' + product_id, dataType: 'json', success: function(json) { $('.alert').remove(); if (json['success']) { $("div.hover-product").hide(); $("#notification .modal-footer"); $("#notification").modal('show'); $("#notification h4").html(json['compare-heading']); $("#notification .mod-text").html(json['success']); $("#notification .mod-image").html(json['product_pic']); $("#notification .modal-footer").html(json['product_pic']); $('#compare-total').html(json['total']); } } }); }, 'remove': function() { } } 

Opencart version 2.1.x

  • Try using the load () function: api.jquery.com/load . - MasterAlex
  • Thanks, but I still can't figure out where to insert it, I'm still a newbie - tds.dev
  • uploading an html file via load() can be done anywhere, as long as it happens no later than you add data there - MasterAlex

0