-
Notifications
You must be signed in to change notification settings - Fork 157
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BlazorInput two-way binding doesn't work #41
Comments
Change bind-Content to bind-Value. Have a look at, https://github.com/chanan/BlazorStrap/blob/master/src/BlazorStrap/BlazorInput.cshtml |
@IvanJosipovic I cannot get binding to work also. is |
Can confirm this is not functioning properly. Tried various combinations of bind, value, etc. One way binding works, but unfortunately until I can get two way data binding working I cannot start to use this library in my project :(
|
bind-value should work, I will take a look at this when I look at the other issue with form tonight. |
The code looks right to me based on the docs: https://docs.microsoft.com/en-us/aspnet/core/blazor/components?view=aspnetcore-3.0#data-binding Not sure what is wrong. |
Tried adding:
Didnt help either |
I tracked down the problem, but not sure how to solve yet. The issue is that DynamicElement isn't updating value, it most likely need to build an on change event. |
Nice! I'll keep looking into it when I have some time.. So far I have reproduced it in my branch to the point where https://github.com/razfriman/BlazorStrap/pull/1 |
I got basic two way binding support working:
Creating a new build now, I also add /samples/form with a working example. |
Have you had a look at this? This is the implmentation for Blazor's EditForm Input element variants? Might be a good example to follow? |
I am considering changing either just the form/input control or all controls to be actual C# classes instead of razor files (which have a backing C# class anyway). At the same time also take some cues from EditForm control. Any thoughts about this? |
I mean… the linked page does say "Developers building their own input components should use Razor syntax." ;-) |
Can we separate that discussion into its own issue?
Not sure if I broke that, but this fails on load with:
|
About the binding - I wont want to do anything till 1.0 is final - lets talk about it again at that time? About the error - I will take a look tonight, but I was also wondering if this is still needed: https://github.com/chanan/BlazorStrap/blob/master/src/BlazorStrap/DynamicElement.cs#L90-L131 |
Oh, interesting. They closed dotnet/aspnetcore#10357. On the one hand, that's great — I considered that piece of code a hack. :) On the other hand, I fear we found the reason for my error above. |
From looking at documentation and samples it appears the razor.g.cs file should contain onchange statements like below. I'm not any in mine and two way binding is not working on any of my samples. builder.AddAttribute(5, "onchange", Microsoft.AspNetCore.Components.EventCallback.Factory.CreateBinder(this, __value => Title = __value, Title)); |
Having some issues upgrading to preview6, I will take another look at this once that is done |
It seems the syntax for binding has changed. Most examples found on line look like this and do not work: The new syntax with @Bind seems ok: This commit on May 30 changed the syntax: |
Yes, that's correct. In preview 6, you're actually supposed to use |
I updated the syntax in v1.0.0-preview6-10 please let me know what you think |
Current status: Per current documentation (preview6) BlazorIntput has:
Which seems to work more or less ok (I think there are still some issues). I am hesitant to change more for two reasons:
Due to the above, I am going to wait a bit and see what Blazor brings before attempting to further solve these issues. PS - Basic binding does work, please try it out and let me know how it goes |
When using the BlazorInput tag you are unable to use two-way binding to the value.
Change text and press submit.
The text was updated successfully, but these errors were encountered: