I'm trying to create a copy of my ViewModel object by serializing and deserializing it:
var copyOfObj= ko.mapping.fromJSON(ko.toJSON(myViewModel))
If i do some manipulation on objects i got following error:
Uncaught TypeError: Accessing selectionDirection on an input element that cannot have a selection.
Hope someone will be able to explain me this issue
Thanks
P.S.
Now i'm starting to think it is something to do with edit dialog form with inputs binded to values of this view model
I was seeing this same issue, and in my case it was due to a jQuery object as a property of my viewmodel. It was infinite looping for a reason I'm not sure of.
Once I removed the property, everything started working
Related
I have an error in my application which only happens when a user double clicks a command link.
What appears to be happening is that the first click correctly does the post then redirect and creates new instances of the WebBeans with the correct view param against them.
The second click tries to restore the old view in the POST, which will nolonger exist so creates a new one and new ViewScoped beans associated. When it comes to reading the view param in the #PostConstruct this is null and an exception is thrown later in the code.
Has anyone experienced something like this? How's best to code around it? I'm trying to avoid detecting and stopping this on the client since I'd like to understand the problem more rather than hiding it behind JS!
I'd like to use this existing MenuItem to use shapes for certain menu items. However I'd like a field to input URL like Custom Link has. So I've added new Input field to ShapeMenuItem ... But so far I'm unable to access it's value in shapes themselves
I've tried
<a class="highlight" href="#Model.Content.ContentItem.ShapeMenuItem.Url.Value">#Model.MenuItem.Text</a>
But that gives me server error Cannot perform runtime binding on a null reference
Any ideas?
Ok it was just stupid me again in late hours, it's supposed to be
#Model.MenuItem.Content.ContentItem.ShapeMenuItem.Url.Value
I have a nested control (NC1) which contains 3 instances of NC2. When the containing view is first opened, NC1 will be null and so the three instances of NC2 will be null. This appears to work correctly based on debugging through my code and the framework.
When a selection is made in the containing view NC1 is properly set (and the ViewModel is (re)created) and values for its properties (exposed through Fody.Expose) appear in the view. However, none of the ViewModels for NC2 are (re)created and they do not reflect the values provided by their respective models.
I am not sure exactly what information to provide without uploading a lot of content, so I will take a stab.
In the NC1 view, I have the following
<localViews:NC2 DataContext="NC2Entry1"/>
<localViews:NC2 DataContext="NC2Entry2"/>
<localViews:NC2 DataContext="NC2Entry3"/>
NC2EntryX are properties on the NC1 ViewModel that return a specific instance of an NC2 model from a list. The NC2EntryX properties is NOT registered with RegisterProperty.
As a note, I have discovered that I must have an empty parameter constructor for the NC1 and NC2 view models. If I do not, then I receive a MissingMethod exception when the view model is being created when the TypeFactory attempts to create the ViewModel with the Activator instead of using the injection path. The injection path is not used because the call at line 591 of TypeFactory returns false because the NC2 model passed is 'not registered'. (Not sure if it should be or how to make it so.)
I am using Catel version 3.9.0
The NC2EntryX property changes must be reflected to the view somehow. You can do this by making it Catel properties, or by calling RaisePropertyChanged("NC2EntryX") yourself when setting the property value. Only in that case the view will be updated (this is just standard WPF / MVVM behavior).
About the missing method exception: it is a first chance exception where the TypeFactory tries to fall back to Activator.CreateInstance when it fails to create the type with dependency injection. No need to worry about this. If you don't want view models to be alive without a model, don't create an empty constructor.
I'm trying to open a View with a ViewModel from my MainWindowViewModel.
It works, but all I get is a blank window. It binds the correct title but every other control is missing.
Did anyone have the same problem and found a solution?
You forgot the call to InitializeComponent in your code-behind. Just a tip: create a base class with the Catel behaviors, then use that as a base view. It will keep your actual window code-behind much cleaner.
I have a list on my view model that contains an object and property that I am trying to bind to from the main view.
var field = new UITextField();
Add(field);
this.AddBindings(
new Dictionary<object, string>()
{
{ field, "Text Names[0].Value" }
}
);
This will load fine and display the initial value from the view model but won't receive any values back when UITextField.Text is modified. It seems like it is not 2 way. Value is not a notification property but could be made into one if that is what this setup requires.
I also tried the following but that does work at all:
set.Bind(field).To(vm => vm.Names[0].Value);
Using MvvmCross 3.0.9. Xamarin.iOS 6.3.7
I've just tested this using 3.0.9 with a ViewModel which has an ObservableCollection of non-INPC Thing objects and this two way binding seems to work OK for me - both when the ObservableCollection changes and when the UITextField value changes because of user action.
Can you provide any more of your ViewModel nad list object code? (If not, can you reproduce the error in a simple sample?)
Can you provide any error trace you are seeing (in debug|output)? (This may need enabling - see MvvmCross Mvx.Trace usage)
Can you provide any more information on the form that "does work at all" - this might be a clue about what is going wrong.