Enable condition for click binding

前端 未结 4 1977
慢半拍i
慢半拍i 2020-12-17 00:07

Is there any way to specify an enable condition for the click binding? For example if I have the following:

Clic
4条回答
  •  猫巷女王i
    2020-12-17 01:00

    It's actually a good amount simpler than any of these options. You can't make the binding conditional but you can make what function is fired conditional. Just use a conditional in the binding:

    Click Me

    That will either fire toggleDialog() or an anonymous function(){} that does nothing.

    You can even stack bound properties to disable the button itself:

    Click Me

    Or have another function that runs in response to an unmet condition:

    Click Me

    Hope this helps

提交回复
热议问题