Answer the question
In order to leave comments, you need to log in
How to load data from JSON after changing content via DOM?
Hello everyone)
I would be grateful for the hint in the implementation of the following.
There is a page (on bootstrap 5) with a number of different features for a particular product that are not initially rendered.
When a user enters it, he must initially select the product of interest to him.
This is how my page looks like (shortened for example and left the main blocks for which there is a question):
<!doctype html>
<html lang="ru">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6" crossorigin="anonymous">
<title>Название</title>
</head>
<body>
<ul>
<li onclick="product1()">Product 1</li>
</ul>
<p id="productOne">[укажите продукт]</p>
<a href="#" id="myProduct1" data-bs-toggle="modal" data-bs-target="#blockModal">I am descreption "Product 1 (отдельная, постоянная ссылка)</a>
<script src="js/all-product.js"></script>
<!--
Содержимое "all-product.js":
function product1() {
document.getElementById("productOne").innerHTML = '<a href="#" id="myProduct1" data-bs-toggle="modal" data-bs-target="#blockModal">I am descreption "Product 1</a>"';
}
-->
<script src="js/date-for-modal.js"></script>
<!--
Содержимое "date-for-modal.js" в формате json с различными данными по по определенным "продуктам"
-->
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-JEW9xMcG8R+pH31jmWH6WWP0WintQrMb4s7ZOdauHnUtxwoG2vI5DkLtS3qm9Ekf" crossorigin="anonymous"></script>
</body>
</html>
$('#productOne').html('<a href="#" id="myProduct1" data-bs-toggle="modal" data-bs-target="#blockModal">I am descreption "Product 1</a>');
function product1() {
document.getElementById("productOne").innerHTML ='<a href="#" id="myProduct1" data-bs-toggle="modal" data-bs-target="#blockModal">I am descreption "Product 1</a>';
}
Answer the question
In order to leave comments, you need to log in
Can you please tell me if it is possible somehow to load data into the model window after adding/updating elements with content?! And in general, is it possible to do this?!
var recipient = button.getAttribute('data-bs-whatever');
modalTitle.textContent = 'Запрос цены ' + recipient;
When a user enters it, he must initially select the product of interest to him.What does it mean to choose? What is this, a selector?
Let's say a person selected "Product 1"Yes, what kind of "choose" this one ???
(there are actually several products, and for each there is a function in the file that changes/updates the data in the corresponding div, p or span tag).Harsh...
For some elements (which are loaded as links), I would like to display a more detailed description in the modal window, but this does not work for me.Link descriptions? Elements? On what action should the modal window appear? By click? To the product link? Or where?
Can you please tell me if it is possible somehow to load data into the model window after adding/updating elements with content?!What kind of elements with content - new products? Or do the products stay the same, only the descriptions change?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question