File tree Expand file tree Collapse file tree
src/components/BootstrapBlazor.Region/Components Expand file tree Collapse file tree Original file line number Diff line number Diff line change 2323 <ul >
2424 @foreach ( var city in GetCities (item ))
2525 {
26- <li class =" " >@city </li >
26+ <li class =" @GetActiveClass(city) " @onclick = " () => OnSelectCity(city) " >@city </li >
2727 }
2828 </ul >
2929 </div >
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ public partial class SelectCity
1616 . AddClassFromAttributes ( AdditionalAttributes )
1717 . Build ( ) ;
1818
19+ private readonly HashSet < string > _values = [ ] ;
20+
21+ private string ? GetActiveClass ( string item ) => _values . Contains ( item ) ? "active" : null ;
22+
1923 private async Task OnClearValue ( )
2024 {
2125 CurrentValue = "" ;
@@ -26,6 +30,19 @@ private async Task OnClearValue()
2630 }
2731 }
2832
33+ private void OnSelectCity ( string item )
34+ {
35+ if ( _values . Contains ( item ) )
36+ {
37+ _values . Remove ( item ) ;
38+ }
39+ else
40+ {
41+ _values . Add ( item ) ;
42+ }
43+ CurrentValue = string . Join ( "," , _values ) ;
44+ }
45+
2946 private static HashSet < string > GetProvinces ( )
3047 {
3148 return
You can’t perform that action at this time.
0 commit comments