Comments (12)
Is the syntax difference between custom tags and custom functions important for you?
If it is not important for you, you can simply create a
popconfirm
function and use it like this:popconfirm(title="Are you sure delete this task?", onConfirm=confirm, onCancel=cancel, okText="Yes", cancelText="No") { <a href=" ">Delete</a > }
Please, show the body (with return type) of popconfirm
from binding.scala.
Is the syntax difference between custom tags and custom functions important for you?
If it is not important for you, you can simply create a popconfirm
function and use it like this:
popconfirm(title="Are you sure delete this task?",
onConfirm=confirm,
onCancel=cancel,
okText="Yes",
cancelText="No") {
<a href=" ">Delete</a >
}
from binding.scala.
I have to admit that the syntax is important for me. I'm not sure for other people whether it is important or not? In my opinion, syntax is one reason why Binding.scala is more charming than other alternatives.
For example, in ScalaTags and HTML literal which one you will choose to use?
Syntax matters a lot. In this particular example, using the popconfirm
function is indeed more flexible and general. But custom tags syntax has the power to reduce the flexibility and make it simple and consistent.
As for me, I'm developing a library(https://github.com/sadhen/Binding-SemanticUI) based on Binding.scala and SemanticUI to provide easy-to-use custom tags like Ant Design(http://ant.design), so that programmers already familiar with Ant Design would be happy to use Binding.scala.
from binding.scala.
I found a more acceptable work around:
<div>
<Popconfirm title="Are you sure delete this task?"
onConfirm={confirm}
onCancel={cancel}
okText="Yes"
cancelText="No"
inner={
<a href="#">Delete</a>
}/>
</div>
Comparing with
<div> {
popconfirm(title="Are you sure delete this task?",
onConfirm=confirm,
onCancel=cancel,
okText="Yes",
cancelText="No") {
<a href="#">Delete</a >
}
} </div>
, which one do you prefer ?
I prefer the former one. However, using the latter one, we would have more IDE support.
from binding.scala.
+1, that would be awesome
from binding.scala.
This would be great for consuming web components, such as the ones defined by Polymer.
from binding.scala.
import com.thoughtworks.binding.dom
import org.scalajs.dom.raw._
import org.scalajs.dom.document
@dom def popconfirm(
title: String,
okText: String, cancelText: String,
onConfirm: Event => Unit, onCancel: Event => Unit
)(
// For FXML, use `Binding[Node]` instead of `Node`
message: Node
) = {
<section>
<h3>{ title }</h3>
<div>
{ message }
</div>
<button type="button" onclick={onConfirm}>{
okText
}</button>
<button type="button" onclick={onCancel}>{
cancelText
}</button>
</section>
}
@dom
def render = popconfirm(title="Are you sure delete this task?",
onConfirm={ _ =>
println("confirm")
},
onCancel={ _ =>
println("cancel")
},
okText="Yes",
cancelText="No") {
<a href=" ">Delete</a >
}.bind // .bind should be avoided for FXML
dom.render(document.body, render)
from binding.scala.
Thanks a lot!
from binding.scala.
But if I'd like to get instead of message: Node
different types, Binding[Node]
, BindingSeq[Node]
, Binding[Option[Node]]
? Can you propose anything? Is there any common type?
from binding.scala.
from binding.scala.
Thanks, my thought were around BindingSeq[Node]
, but converting makes code less readable.
from binding.scala.
I'm trying to implement the inner html feature in https://github.com/sadhen/Binding-SemanticUI
from binding.scala.
Related Issues (20)
- FXML: Enable opening pop-up window at a specified location
- Null cache exception in FlatMap HOT 8
- Entity references in attribute values do not compile
- Referring to non-existent method com.thoughtworks.binding.FutureBinding$.apply(scala.concurrent.Future,scala.concurrent.ExecutionContext) HOT 1
- Event handlers in custom tags HOT 1
- data prefix does not (it should) set the attribute to null if the initial value is null HOT 1
- FutureBinding compare with React hooks HOT 1
- Make Binding.value be public HOT 16
- Vars.all is not triggerred HOT 2
- := deprecated, how to use value_= ? HOT 3
- dom module is missing for version `12.0.0-M0` HOT 1
- V12 eta HOT 2
- Vars size binding HOT 3
- Conversion from Binding[Iterable[A]] to BindingSeq[A] HOT 4
- Using BindingSeq in an implicit value class HOT 1
- Use @html to create a table, what is returned is scala.xml.NodeBuffer, and what is needed is BindableSeq[org.scalajs.dom.Node], how to convert? HOT 4
- Dependency `scalajs-dom` is out dated HOT 1
- The last element in HTML interpolation are inserted twice (Binding.scala 13.x)
- Code in `ReadMe.md` failed for unkonow reason. HOT 8
- Support for `Scala.js1.x` & `Scala2.12`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from binding.scala.