Commit b8bd7bd2 authored by 杨博 (Yang Bo)'s avatar 杨博 (Yang Bo) Committed by Sam Saccone

Render the Binding.scala's TodoMVP application into a div instead of body (#1663)

Render the Binding.scala's TodoMVP application into a div instead of body
parent 9e22e76c
......@@ -23,7 +23,8 @@ indexHtml := {
<body>
<script type="text/javascript" src="node_modules/todomvc-common/base.js"></script>
<script type="text/javascript" src={ linkedJs.file.relativeTo(baseDirectory.value).get.toString }></script>
<script type="text/javascript"> com.thoughtworks.todo.Main().main() </script>
<div id="application-container"></div>
<script type="text/javascript"> com.thoughtworks.todo.Main().main(document.getElementById('application-container')) </script>
</body>
</html>
val outputFile = baseDirectory.value / "index.html"
......
......@@ -9,6 +9,7 @@
<body>
<script type="text/javascript" src="node_modules/todomvc-common/base.js"></script>
<script type="text/javascript" src="js/js-opt.js"></script>
<script type="text/javascript"> com.thoughtworks.todo.Main().main() </script>
<div id="application-container"></div>
<script type="text/javascript"> com.thoughtworks.todo.Main().main(document.getElementById('application-container')) </script>
</body>
</html>
This diff is collapsed.
This diff is collapsed.
......@@ -3,7 +3,7 @@ package com.thoughtworks.todo
import com.thoughtworks.binding.{Binding, dom}
import com.thoughtworks.binding.Binding.{BindingSeq, Constants, Var, Vars}
import scala.scalajs.js.annotation.JSExport
import org.scalajs.dom.{document, Event, KeyboardEvent, window}
import org.scalajs.dom.{Event, KeyboardEvent, window}
import org.scalajs.dom.ext.{KeyCode, LocalStorage}
import org.scalajs.dom.raw.{HTMLInputElement, Node}
import upickle.default.{read, write}
......@@ -140,7 +140,7 @@ import upickle.default.{read, write}
</footer>
}
@dom def todoapp: Binding[BindingSeq[Node]] = {
@JSExport @dom def todoapp: Binding[BindingSeq[Node]] = {
<section class="todoapp">{ header.bind }{ mainSection.bind }{ footer.bind }</section>
<footer class="info">
<p>Double-click to edit a todo</p>
......@@ -149,6 +149,6 @@ import upickle.default.{read, write}
</footer>
}
@JSExport def main() = dom.render(document.body, todoapp)
@JSExport def main(container: Node) = dom.render(container, todoapp)
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment