I am trying to create a list of contacts, where I have two views.
One view that lists all the contacts and gives the option to add a new contact, being a button, not an actual space where I put the information.
The other views is when I click on the plus sign, that would give me the field to put a new information.
What I am trying to do is using angular, after I put all the information in the field, have updated on the array. My idea is that since I am not refreshing the page, the array should contain the new added contact, but it's not happening.
Do you guys know why?
I could put the code here, but honestly I just want to know if what I am trying to do is hypothetically possible
Edit: Everything was fixed using a factory ;). Thank you guys.
If I get you correctly I think what you need is a service to hold the contacts, that way if you update the service your scope property for the contacts updates as well
Related
I'm a Junior Developer and I'm currently having a big issue with breadcrumbs.
For this application, I'm using VueJS and the problem I'm having is the following:
*The user clicks on 'tables' and is sent to the 'tables' page.
-On that 'tables' page, he has a big table in which he's able to click on the various columns to show a new table with data relevant to the column he clicked on.
*For this I'm on the same component so I'm not using routers, but using v-show as I don't want the tables to rerender.
My problem is the following, I have to make a breadcrumbs as he navigates to the different tables (ie: table/holdingList/entrepriseList/clientList..). and they have to be clickable so that I'm able to create a function that injects data into the table or to simply 'show' it and close the others.
Can anyone give me a brief out-line of how to do this? Sorry if it seems trivial. I've already spent a couple of days on it and my brain has turned to mush...
I will start from the easiest solution to implement:
Each v-show will depend on a different data object. Then your breadcrumb has an #click method that will set every v-show data object to false. Give the method a parameter with the name of the data object that you intend to show and display that to true.
The previous answer is enough to get it working. Other ways of achieving the same result in a more maintainable way are:
Create one data object named as activeTable and turn your v-show into a v-if. When you click on the breadcrumb element you change the activeTable data object to an identifier for the table you wish to display. After that your vue-if simply checks if the activeTable === thisTableId. Where thisTableId is the identifier of each table.
You may want to start getting acquainted with Vuex specially if your tables share a similar layout. In that way you will store the data and there is no need to request your data again. This is useful if the data to populate your tables come from an API.
Finally on an SPA architecture there is no actual re-render so you may possibly want to look at that as well.
Please read the guidelines for posting an answer since they require you to show at least some effort from your side. Good Luck!
I am trying to create a simple app that forces the user to enter a reason for update or delete when they are editing an existing model through a form. I have created the model and the associated form. The part of the model that asks for the update summary works fine, but when it appears, it obviously always has the last update that was entered for the model as part of the update view. Is there some way I can "blank out" the update summary every time? I am also trying to create a history of each form and I'm still in the early stages of that. I see that there are several options available, but I'm still exploring those. I'm a newbie, so any help you can offer is appreciated!
Here is a copy of my current model:
class Pizza(models.Model):
pizza_name = models.CharField(max_length=264,unique=True)
customer = models.TextField(max_length=264,unique=True)
update_summary = models.TextField(max_length=264,unique=True,null=True)
I have explored possible using Javascript to blank out the form in the update view but can't seem to get that to work. I have also considered trying to override the form in the form view, but can't seem to get that to work either. I ultimately want the update view to show the pizza_name every time as well as the customer view, but I want the update_summary to be blank every time. I intend to store every update summary on a separate history record to be viewed in a history view somewhere but am working to figure out how to best approach this as well.
Thanks in advance for your help!
I'm going to try and put this in the simplest terms and hopefully someone can help me. I'm new to MVC and i'm trying to learn the ropes.
I have an dropdown that is populated with tenant objects.
I want a user to be able to select a tenant in the drop down, and have that tenant added to a list (Enumerable of Tenant objects) and displayed below the dropdown in a section called "Added Tenants" while also removing the selected tenant from the dropdown.
I don't want these tenants added to the database until later because this is a form creating a lease, and i want them to finish filling out the rest of the lease and create it all at once.
I'm hoping someone can help me or at least point me in the right direction. Yes i have done searches but haven't found anything yet that will help me or that i understood.
Edit: The list can be of object, just an id, or even a select list. The end game is to use that list to add them to the collection which is a 1 to many relationship. That list will also be used to populate partial views with the tenant information, kind of like how the tags work in stack overflow.
While it's not clear what the "list" is that you want added to (i.e. a UL or a form select list), but this solution is going to be done in javascript, not ASP.
Try doing a few searches on SO. Such as:
jQuery moving MultiSelect values to another MultiSelect
I have an app I've been building that displays products from an array. Using Angular.JS, I can pull this array to generate on my view. In my view, a client can sort and filter the list to find exactly what they want. Is there a way to save those filters, so if they were to click an item, go to that corresponding page, then come back?
As of right now, it will always load all results without filters, even if a client has clicked a filter or two before hand.
Is there anyway to save their selections or previous activity?
There's more than one way to do what you want:
Using $cookies(https://docs.angularjs.org/api/ngCookies/service/$cookies);
Using localstorage( I use this module, it's very good - https://github.com/gsklee/ngStorage);
using $cacheFactory(https://docs.angularjs.org/api/ng/service/$cacheFactory), but with this option you will lose the data if user leaves the session;
In all cases, the idea is to save the filters and selection on the desired location and retrieve i when necessary.
hope it helps
At a high level, building an application that allows User to request Items from other Users located in the same county as the requesting User. User and Item are both models with associated databases.
On the request page, I'm trying to build 3 components.
1) A map that shows
A marker for each other User
When clicked on, the marker displays a popup that lists the Items that that User has. The requesting user can click on each Item to add it to the list of Items s/he would like to request
2) A set of search fields that allows the requesting user to filter the markers for Users and Items on the map, for example, perhaps by dates_available.
3) A "cart" (not literally since this is not about e-commerce) that shows the Items the requesting User has currently added, with a final submit button. Note, dates_available should not only be a search field, but also part of this Request
A not perfect example is this screenshot from Getaround:
I'm pretty new to coding in general, so always want to think through plugins, APIs, shortcuts, etc. The below is just for reference, but if you have comments on how to implement this better, PLEASE do tell me! Right now, I am currently thinking of using:
For the map:
Openlayers.org
Gmaps.js
For the search (which is really a filtering capability):
Ransack gem (https://github.com/activerecord-hackery/ransack)
THE KEY QUESTION
For the "cart" and the click Item to add to "queue" part, I realize that while I can do this in Rails purely, it might be less of a positive UX experience since the page would constantly re-render every time a new item were added, not to mention it'd potentially result in excessive pings to the database or records to be created. I'm thinking of using Javascript to basically make the "cart/queue" a staging area for temporary storage, where the User populates it with whatever Items s/he wants and edits as needed, but it's not until the final submit click that the entire group of Items is passed as a Hash to the Rails Controller to be saved.
Now, since I don't really know JS very well, any resources on how to do this (easy plug-in solutions, other considerations I may have missed) or if it's not possible (in which case pray tell) would be greatly appreciated.
Thanks!
You may try Javascript localStorage.
localStorage.myTempValue = "my temp value";
or
localStorage("key", "value");
You can store object:
var person = { name: "xxxxx", age: 35 };
localStorage.Person = person;
Hope my answer may trigger an idea in you!