I can also share snippets along the way if that's simpler. :)
I'm making a <ul> of objects using jQuery as soon as my page loads. I used a constructor to make a bunch of Fruits
Now that I have my Fruits I want to sort them. I want to have two buttons on the page. One that will sort them by calories, one that will sort them by gLoad.
Rachel Kudrna
@rkudrna
...
so, here's where I get confused
I need to make an array of Fruits
I can do that by passing my variable names into an array, but that doesn't seem to be an interaction with the DOM. Right?
I'm thinking there's a way to query for all <li>s, but will they maintain their status as objects with properties I can sort them by?
Samantha Camus
@xdothackerx
Uhhh give me a minute to download all your stuff and take a look. XD
Rachel Kudrna
@rkudrna
sure thing. :) Let me know when you've had a chance to take a peek.
Samantha Camus
@xdothackerx
Is there a reason why you want to query the DOM for the fruit objects instead of just adding them to an array when they're instantiated?
Rachel Kudrna
@rkudrna
I'm thinking of adding an animation of the sorting. Can I do that when I'm just adding them to the array in the js file?
(it's entirely possible that I'm overthinking how this ought to work)
Samantha Camus
@xdothackerx
It'd probably be easier to add them to an array when they're instantiated, then have animations during each of the two sort functions.
Rachel Kudrna
@rkudrna
ah, okay
_
Samantha Camus
@xdothackerx
So you'd have the original array of all your fruits, then you'd iterate through each one to sort it by the desired property. During that iteration is when you'd animate the fruit moving from one order to the other, kind of like how Brook did the sort algorithm thingie in class.
Does that make sense? XD
Rachel Kudrna
@rkudrna
Yes, in theory. :) I'll look at his code again and see if I can adapt it to my project.
Samantha Camus
@xdothackerx
Okie doke! Let me know if you have any more questions.
Rachel Kudrna
@rkudrna
Seems like it'll be much simpler to do that than what I was thinking....
thanks!
Samantha Camus
@xdothackerx
No prob!
Hiro-Protagonist
@Hiro-Protagonist
eek!
I'm finishing the prework tonight/next few days
will it still get graded?
:D
Samantha Camus
@xdothackerx
Yup, I'll be grading until October 15th. :)
HeyIamJames
@HeyIamJames
I will be taking advantage of that ^ I am working on making a program to sort an un ordered list into an array, then into a complete binary tree, then search for an element (all animated).. and it's not really working right now