feat(wip): add function call examples
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
||||
package com.baeldung.thymeleaf.controller;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.ui.Model;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
|
||||
@Controller
|
||||
public class FunctionCallController {
|
||||
|
||||
@RequestMapping(value = "/function-call", method = RequestMethod.GET)
|
||||
public String getExampleHTML(Model model) {
|
||||
model.addAttribute("num", 2);
|
||||
return "functionCall.html";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<title>Thymeleaf: Javascript function call</title>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
<div> Thymeleaf: Javascript function call </div>
|
||||
</header>
|
||||
|
||||
<main>
|
||||
<section>
|
||||
<div>Inline function call</div>
|
||||
<div>
|
||||
<header>Without a variable</header>
|
||||
<button th:onclick="'alert(\'a\');'">Without variable</button>
|
||||
</div>
|
||||
<div>
|
||||
<header>With a variable</header>
|
||||
<button th:onclick="'alert(\'' + ${num} + '\');'">With variable</button>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user