0
function show_modal(val1, val2){
    {% set msg1 = val1 %}
    {% set msg2 = val2 %}
    document.getElementById('id01').style.display='block'
}

I have calling show_modal() function in some where in the template.

Needs each time assigning situational values to msg1 and msg2

Not working. Each not working below:

function show_modal(){
    {% set msg1 = "Delete Column" %}
    {% set msg2 = "Are you sure you want to delete this column?" %}
    document.getElementById('id01').style.display='block'
}

May I show different prompts with this part of code? (Which is invisible by default)

<div id="id01" class="modal">
        <h1>{{ msg1 }}</h1>
        <p>{{ msg2 }}</p>
</div>
4
  • Are you using external js file or the js code is within HTML file? Commented Jan 15, 2023 at 23:25
  • @itsmehemant7 Within template (HTML file). Commented Jan 15, 2023 at 23:28
  • After the page rendered, I can using {% set msg1 = "Delete Column" %} or {% set count = namespace(value=0) %} and so on... Commented Jan 15, 2023 at 23:36
  • In this case user click on Delete button and I need show him a warning prompt. This prompt have difference for each delete button. The page contains several Delete button Commented Jan 15, 2023 at 23:38

1 Answer 1

1

You have to use pure js for this, try something like this:

function show_modal(){
   let msg1 = "Delete Column";
   let msg2 = "Are you sure you want to delete this column?";
   document.getElementById("id01").innerHTML=`
     <h1>${msg1}</h1>
     <p>${msg2}</p>`;
   document.getElementById('id01').style.display='block'
 }

<div id="id01" class="modal">
</div>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.