Reputation: 769
This is my code:
extends layout
block content
h1= title
div(id="rename", class="Name", onload='name("rename", "editor")')
form(id = "filename", method ="post")
input(id="new_name", type ="text", placeholder="File Name")
input(id="Okay", type="submit", value="Okay")
div(id="editor")
|Welcome to the home pages
|This is the first Paragraph
script(src="javascripts/ace.js", type="text/javascript")
script.
var editor=ace.edit("editor")
script(src="/jvm.js", type="text/javascript")
script.
function name(id, id2){
document.getElementById(id).style.display = 'block';
document.getElementById(id2).style.display = 'none';
//document.getElementById(id3).style.display = 'none';
}
When I run it on the web, my javascript function is not being called. I can't seem to figure out why, however I think it has to do with syntax. I don't think I am using the right quotations when I am calling the function.
Here is how it looks when I inspect elements on the web browser.
Upvotes: 0
Views: 1223
Reputation: 106696
You need to set the onload
attribute on the <body>
, not any other tag. Or you could add a snippet of javascript on the page to do the same thing:
window.onload = function() { name("rename", "editor"); });
Upvotes: 1