What I am trying to do is use a navigation link to open another view and in the second view use a variable from the first view. No matter what I try I can't seem to make it work. I'm new to coding so my knowledge is limited and I can't find a solution.
I want to get the value of the take off mass in the table:
and, for now, change the "yet another attempt" to the same value:
Any help would be greatly appreciated!
Related
I'm starting to learn swiftUI and I have a strange problem,
I have created a simple list that displays perfectly in the preview... But not in the simulator.
Does anyone have an idea?
https://www.dropbox.com/s/eo1ldvdbgntzr8v/Enregistrement%20de%20l%E2%80%99%C3%A9cran%202021-06-04%20%C3%A0%2018.42.03.mov?dl=0
Project : https://github.com/maxupcreation/Dfi/tree/main/Dfi
to answer more correctly, you'd better show us yout whole source code.
it seems second view(maybe AddChallengeView.swift file)'s input cannot reflect to original view(=ContentView.swift)'s List. so there might be two problems
because you refer your "items" property from another view, you'd better check if you use ObservableObject protocol and #ObservedObject property wrapper properly.
at ForEach statement, you use nil coalescing, so check whether item value is nil
I'm working on an app that involves inputting the amount of cards players ended up with, and ordering them in a list. But if theres a 2 or 3 way tie, I want the user to be able to have a menu that lets them select the order of who had the highest card to lowest card, that way I can organize the list. How do I get the user to order them, like what kind of Alert/Popup lets me do that?
Edit: Basically I was asking how to make a picker that lets you arrange multiple items into a specific order but it seems the best thing to do is just to have a stack appear with buttons for each item, where you can click them and go from there to create your order. Hope this helps for anyone in a similar situation!
For that kind of user interaction where they are doing more than just tapping an option (in your case, you want them to order the various cards), I would create your own custom view rather than use an alert or action sheet or similar.
The way you implement will depend on how you want it to look. If you want the view to appear on top of your current view (a bit like an alert does) where it only takes up the space needed for the content) then you can embed in a zStack. If you want it to slide up from the bottom as almost the same size as the full screen then you can use a sheet (sometimes also referred to as a modal).
A little difficult to explain how they look visually - if you google image search “SwiftUI sheet” then you’ll see what I mean (if you aren’t already familiar with them)
ZStack
you put your current view in a ZStack then create a new view which goes in the ZStack after it but you wrap it in an if statement so it’s conditionally shown based on a Boolean being true.
E.g.
if gameTied { ChooseSortOrderView() }
then when your game finishes - if it’s a tie, you set your Boolean to true and up pops the new view.
You can pass in the tied cards, get the user to sort them via drag and drop, form, picker (whatever you want), submit it. Then set the bool back to false to make the view go away.
sheet
The other alternative instead of using a zstack would be sheet so you get a modal view appear. Similar approach but instead of the ZStack, you use a .sheet modifier.
I am right a project and I need to be able to access the name of the previous view.
So, for instance, if I'm on page 1 and I navigate to page 2, I want to know that I came from page 1.
Basically I have a view that can be accessed from a number of screens and the content of that view will depend on the screen that if came from.
I know I can do this by passing the name across in a function, but I am wondering if there is a nicer way of doing this.
I tried some implementations with the historylocation class but I could get it working. The url kept being sent back to the base url every time I created an instance of the historylocation, which was weird.
I also see that there might be a way to do this in the router by adding
location: 'history'
but I don't know how to get this to start working afterwards then, to access the correct view name i.e. current/previous
There a way of getting this through the browser history too I guess but I was hoping to do it with Ember.
Any one have any ideas how to get these to work or better ways to do it?
I have the following problem with ember.
I have a table with a set of datas. I have an event that returns me the current element of the table. Then it opens another view by transitioning into a new state and writes the selected table data in a textfield.
click: function(e) {
var element = $(e.target).closest("td");
App.tee = element.text().trim();
var router;
router = this.get('controller.target.router');
router.transitionTo('newRoute')
As you can see I have some other routes in my router as well.
The last two routes(home and profile) are part of a nav-tab. They work perfectly beside I click on the table. Then i get the following error when i click on a tab: Uncaught TypeError: Cannot read property 'enterStates' of undefined
Ok i give it another try to explain what i wanted to do.
What i want to do is to create a table with some data (for example persons).
When i click on a specific person in the table the corresponding table-data should be shown in the textfields that appear below. Whenever i click on another person the textfields below should change to the informations of the current clicked person in the table. When i click "New" Button a more detailed Tabview appears on the right side with some additional informations. I was playing around with ember and so far i just implemented some of the views and the routing. Im stucked as i have tried to implement the event that updates the textfield below the table. It updates once but after it has transitioned into the new state(newRoute) nothing happens. I know the code is very raw, but it is just a test to understand how this works in ember.
Ok the solution was easier than i thought. The problem was not the state changing. It was more a problem of how to access the data and how to effect the change of binded data. I realised too late that i needed to understand how the variable access works in Ember and what exactly the App.initialize() method does. So App.initialize() initializes all Controller classes in the router. If you want to access any variables within a controller you have to get the access over the router like
{{view Ember.TextField valueBinding="App.router.tableController.person"}}
Secondly i wasnt familiar with the usage of the set and get methods in Ember and the difference between extend and create. I wondered before where ember instantiates my object.
So my problem had nothing to do with states it was just a totally misunderstanding of the ember framework. Im a noob thats all.
Ok, this is the first shot of the answer.
I think the main issue is just a typo gotoHome instead of goToHome in the template.
By the way I get rid of some deprecation warnings by using <button {{action }}></button> instead of Ember.Button.
There is some other warnings when I click on the table, because you are referencing some properties which don't exist.
here is the corresponding fiddle: http://jsfiddle.net/Sly7/rKw9A/25/
Since I don't understand how it should work exactly, I'm not sure of the overall behavior. I let you explain me the flow (by editing the question please).
Any other comment is welcome :)
If you look at my brief history of questions, I've seem to have built up a reputation for asking simple questions that I should have figured out the answers to myself, before wasting people's time. With this one though I'm genuinely stumped and I would greatly appreciate some help, so here goes...
I have a multi select list (will eventually use a jquery plugin to make it pretty) that will be populated based on some user criteria (in my example the options are hardcoded, but an example would be a 13 year old shouldn't be able to see rated "Mature" games in my game store).
Based on some search criteria (let's say we are searching by publisher, games available in a specific country, etc..) The counts for each multi-select item, should update as the search criteria changes and the counts change. (In my example I just change a value with a timer)
Here is the fiddle, http://jsfiddle.net/AMPBb/1/
It seems like there are a few ways I could solve this, like a countBinding on my SelectListItem with a displayText computed property, but I can't actually finish a working example. The first option that has the changing count is very hackerish, but demonstrates the functionality that I'm expecting. I haven't come across an example like this before, so I'm very interested in seeing what the best approach to solving this should be.
Thanks in advance for any help.
I would create a computed property label on your App.SelectListItem which is defined as follows, see http://jsfiddle.net/pangratz666/Y6467/
label: function() {
var text = this.get('text');
var value = this.get('value');
return '%# (%#)'.fmt(text, value);
}.property('text', 'value').cacheable()
Also note that you have to create a valueBinding to your 'App.CountModel.*' in your App.SelectListItem.
One more thing about naming convention: concrete instances should be named in lowerCase, so it's App.countModel. See http://www.emberist.com/2012/04/09/naming-conventions.html.