Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Render partial based on select tag


  • Please log in to reply
No replies to this topic

#1 wazon

wazon

    Passenger

  • Members
  • 5 posts

Posted 17 November 2013 - 01:23 AM

Good evening everyone,

I'm trying to render a partial based on a selection made in a select tag. When the select tag changes, I perform a GET action via ajax, but I am unable to show it. This is my jquery code so far:

 

jQuery ->
  subcategories = $('#offer_subcategory_id').html()
  $('#category_name').change ->
    category = $('#category_name :selected').text()
    options = $(subcategories).filter("optgroup[label='#{category}']").html()
    if options
      $('#offer_subcategory_id').html(options)
    else
      $('#offer_subcategory_id').empty()
    $.ajax
      url: "/" + category.toLowerCase() + "s/new"
Could anyone give me a hand?
 
Regards,
Wazon





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users