Maximilian
Lifer
So ive come to the conclusion that shoehorning react or angular into my current project is just not going to work. I realistically need to start a new project and use one of these from the beginning.
Anyways is there a better way of doing data binding than what im currently doing?
This is how its setup:
http://imgur.com/a/ZaoiM
Each food item has a remove button. When it is clicked a jQuery event handler gets the id of the button, the buttons look like this:
And the food with the corresponding number is then removed from the underlying array which stores all the eaten foods. Is there a better way? Some small js framework I can use? Im using handlbars.js for templating and I love it, something like that but with data binding as well would be cool.
SEMI RELATED:
I say the food is removed from the underlying array, its actually not. What happens is:
1. remove clicked
2. request sent to server to remove food from database table
3. food removed from database table
4. updated list of eaten foods sent back to client
5. updated eaten food list replaces clients current eaten food list
6. DOM is updated
That happens with every single removal/addition of a food. It occurred to me that the client could actually just update its own food list and sync up with the server say every 5-10 minutes. Would that be more efficient? What do other websites do?
Anyways is there a better way of doing data binding than what im currently doing?
This is how its setup:
http://imgur.com/a/ZaoiM
Each food item has a remove button. When it is clicked a jQuery event handler gets the id of the button, the buttons look like this:
HTML:
<button type="button" class="btn btn-danger btn-md pull-right" id="136eatenfoodremove">Remove <span class="glyphicon glyphicon-remove"></span></button>
And the food with the corresponding number is then removed from the underlying array which stores all the eaten foods. Is there a better way? Some small js framework I can use? Im using handlbars.js for templating and I love it, something like that but with data binding as well would be cool.
SEMI RELATED:
I say the food is removed from the underlying array, its actually not. What happens is:
1. remove clicked
2. request sent to server to remove food from database table
3. food removed from database table
4. updated list of eaten foods sent back to client
5. updated eaten food list replaces clients current eaten food list
6. DOM is updated
That happens with every single removal/addition of a food. It occurred to me that the client could actually just update its own food list and sync up with the server say every 5-10 minutes. Would that be more efficient? What do other websites do?