Skip to content

Instantly share code, notes, and snippets.

@axsuul
Created October 17, 2011 08:51
Show Gist options
  • Save axsuul/4c91435aefde9ad5846f to your computer and use it in GitHub Desktop.
Save axsuul/4c91435aefde9ad5846f to your computer and use it in GitHub Desktop.
%ul#filters
- @filters.each do |filter|
%li{:"data-name" => filter.name, :href => filter_url(@url_filters.add_to_url(filter.name))}
$('#filters li a').live 'click', ->
history.pushState(null, "", @href) # This changes the url (not using hash bangs)
$.getScript(@href) # This will call index.js.coffee
class FiltersController < ApplicationController
def index
@url_filters = URLFilters.parse(request.fullpath)
end
end
= javascript_include_tag :filters
= render "filters"
$('#filters li a').each ->
# This is the part I'm having trouble with. The code below obviously won't work but hopefully it'll give you an idea of what I'm trying to do
# But basically I want to update each url filter url to account for the new url when the url changes
$(this).attr('href', '<%= @url_filters.add_to_url($(this).data("name")) %>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment