0

I have this jade file

- if (transactions != "")
    table
        th Site Name
        th Deadline
        th Delete Transaction

        each item in transactions
            tr
                td= item.item_name
                td
                    span(id='countdown'+item.timeout)= item.timeout
                td
                    span(style='cursor: pointer;', onclick='deleteTransaction('+item.uniqueId+')')= "X"

    button(id='confirmButton', onclick='confirm();', value="Confirm", name="Confirm")= "Confirm"
    script
        fillCountdown(transactions);

I don't understand why the function fillCountdown in the last line is never called. I have to say that this page is loaded in a Chrome extension, in the popup, but I guess nothing changes.

Can someone help me? Thanks.

6
  • Have a look at the HTML produced by this jade template. Maybe that will give you an idea. Commented Mar 2, 2012 at 14:11
  • The HTML doesn't show the script tag at all, I already checked that before asking here. And JavaScript doesn't give any error at all. Commented Mar 2, 2012 at 14:27
  • 1
    try script(type="text/javascript") Commented Mar 2, 2012 at 16:49
  • Thanks, now it shows it but it doesn't execute it. Very strange. Commented Mar 2, 2012 at 17:06
  • script code gets executed on the client, not the server. do you intend to do that? Commented Mar 14, 2012 at 23:05

1 Answer 1

3

The problem seems to be the indentation used in jade. After the script tag, you need to give two spaces indentation and then define the function. For e.g.:

body
  script(type='text/javascript')
    function something() {
    alert("Inappropriate Value")
    }

Also check if the script tag is properly indented with the body tag. If you are defining a function inside the script tag, check the script tag is at only one level indentation with the body tag.. In your code snippet it is not clear if the script tag is nested inside the "if" case or properly aligned with the body tag. When I copied your code snippet, your function "fillCountdown" was indented with 4 spaces with the script tag. In jade the indentation is of two spaces.. Hope this solves your problem.

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.