You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There are several key aspects in implementing this:
22
30
23
31
* A tooltip component. See this page for a Telerik one: https://feedback.telerik.com/blazor/1406095-tooltip-support. When it gets implemented, this code will become simpler. The current mockup stores the button coordinates when the mouse enters it. See the code comments for more details.
@@ -111,6 +119,78 @@ There are several key aspects in implementing this:
111
119
}
112
120
````
113
121
122
+
### Per-Input Validation Popups
123
+
124
+
This sample uses a tooltip component and mimics clicks on its targets to make it show up. Comments in the code provide more details on the implementation approach and ideas for next steps in the implementation.
125
+
126
+
>caption Tooltips for validated inputs
127
+
128
+
````CSHTML
129
+
@* This sample shows one way programatically show tooltips and display the validation summary in it. *@
130
+
131
+
@inject IJSRuntime JS
132
+
133
+
<script suppress-error="BL9992">
134
+
// the scripts should be extracted in a separate js file
135
+
window.triggerClick = (id) => {
136
+
document.getElementById(id).click();
137
+
}
138
+
</script>
139
+
140
+
@using System.ComponentModel.DataAnnotations
141
+
@* this is for the validation model only *@
142
+
143
+
<style>
144
+
/* implement desired styling, here we just add white background so the default red text pops out */
Showing individual `ValidationMessage` components for separate components and pointing the tooltip to them is beyond the scope of this article. While an `EditContext` will provide you with some events when validation and fields change, knowing whether a certain field is valid or not is not available out-of-the-box, and connecting this mockup to a particular location (that is, the `Top` and `Left` parameters) in the DOM will require JS Interop code that is highly dependent on the project, form and layout.
0 commit comments