From 8e83adabbd916bebf1023e1108b7e03cf5820f68 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 16 Jul 2015 22:37:04 -0400 Subject: [PATCH] whoops, we broke start from scratch previews when neopia is online xP (I wonder why nobody noticed ;P) --- app/assets/javascripts/outfits/new.js | 16 ++++++++-------- app/helpers/outfits_helper.rb | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/javascripts/outfits/new.js b/app/assets/javascripts/outfits/new.js index e8c53a4e..e00aa27d 100644 --- a/app/assets/javascripts/outfits/new.js +++ b/app/assets/javascripts/outfits/new.js @@ -120,12 +120,12 @@ Preview.Job.Name = function (name) { } } -Preview.Job.Hash = function (hash) { +Preview.Job.Hash = function (hash, form) { Preview.Job.apply(this, [hash, 'cp']); this.visit = function() { - window.location = "/wardrobe?color=" + $('#color').val() + "&species=" + - $('#species').val(); + window.location = "/wardrobe?color=" + form.find('.color').val() + "&species=" + + form.find('.species').val(); } } @@ -181,11 +181,11 @@ $(function () { } }); - var selectFields = $('#species, #color'); - selectFields.change(function () { + $('.species, .color').change(function () { var type = {}, nameComponents = {}; - selectFields.each(function () { - var el = $(this), selectedEl = el.children(':selected'), key = el.attr('id'); + var form = $(this).closest('form'); + form.find('select').each(function () { + var el = $(this), selectedEl = el.children(':selected'), key = el.attr('name'); type[key] = selectedEl.val(); nameComponents[key] = selectedEl.text(); }); @@ -200,7 +200,7 @@ $(function () { success: function (data) { var job; if(data) { - job = new Preview.Job.Hash(data.image_hash); + job = new Preview.Job.Hash(data.image_hash, form); job.name = name; job.setAsCurrent(); } else { diff --git a/app/helpers/outfits_helper.rb b/app/helpers/outfits_helper.rb index 538c042e..ac687c17 100644 --- a/app/helpers/outfits_helper.rb +++ b/app/helpers/outfits_helper.rb @@ -106,8 +106,8 @@ module OutfitsHelper end def pet_attribute_select(name, collection, value=nil) - select_tag name, - options_from_collection_for_select(collection, :id, :human_name, value) + options = options_from_collection_for_select(collection, :id, :human_name, value) + select_tag name, options, id: nil, class: name end def pet_name_tag(options={})