Closed richardescobedo closed 10 years ago
The logic for this needs to be: If office is x, append candidate panel to div x, hide div y. If office is y, append candidate panel to div y, hide div x.
You may want to look at handling these as an HTTP query string
Ah, so generate a URL that only pulls certain data from the table, correct? Because if I'm understanding this correctly, I can use the code that has already even written, I would just create a function for each office I'd want to show.
@achavez, Would using .param()
be the appropriate course of action here? I can reload the page with different parameters using this, correct?
@richardescobedo: Correct. You should be able to have a javascript object that has all of your parameters in it, then you can use .param() to actually build that into a URL that can then be used to link to specific results. I'd probably structure it something like this:
var query = {
width:1680,
height:1050
};
Then, when someone clicks a filter you update query
. query
is then passed to your function that pulls data from Fusion Tables and your data is re-pulled. And it's also serialized by .param()
to setup the URL. You'd also have to then create a function to read the URL, unserialize it and repeat the above process.
If this all seems like a little much now, you may want to just get the filtering working and not worry about altering the URL. You can always go back and add that later.
Thanks, @achavez, that's what I thought. The only thing I'm struggling with is writing the code for this, which is why the development is taking so long. The logic makes perfect sense, though. I really think this can be done by today because the concepts aren't terribly complex.
@achavez Ok, I already have this Javascript object -- should I restructure this, or create an entirely different object that pulls from this?
function initialize() {
var query = "SELECT Name, Committee, Classification, 'Legislation Authored', Photo, Position, Office FROM " +
'1mQXVY2fdbKqduhwyRpzywqqnfdS27k2YnBXAP9NE';
var encodedQuery = encodeURIComponent(query);
// Construct the base URL
var url = ['https://www.googleapis.com/fusiontables/v1/query'];
url.push('?sql=' + encodedQuery);
url.push('&key=AIzaSyBpucsUNf8LQ9VMFS-9E_zRcdhcFlrNm4U');
url.push('&callback=?');
@richardescobedo: You should be able to use this as a starting point. If it were me, I'd probably setup a function that has the sole purpose of pulling from Fusion Tables and takes your params as an input. Then, inside the function, turn your params into a query.
See: http://benalman.com/code/projects/jquery-hashchange/examples/hashchange/ See: http://benalman.com/projects/jquery-bbq-plugin/
If time is of the essence, this may be a better solution: http://api.jquery.com/filter/