Why does JS behavior work in development, but not when I click on Heroku?

I am trying to create a step form - which starts / shows some fields when something else is selected.

Here is an example - http://jsfiddle.net/XnPZF/ - it works (it also works in development).

I just can’t understand why this does not work when I click on Heroka.

Here is the version on Heroku .

Input: abc@test.com / test123

The fields that other fields should run right below it are Property_Type and Category.

Here is the code snippet:

/views/listings/new.html.erb

 <%= simple_form_for @listing, :html => { :class => 'form-horizontal' } do |f| %> <%= f.error_notification %> <fieldset> <%= f.association :property_type %> <div style="display: none;" data-show-for-prop-type="Multi Family"> <h4>Multi-Family</h4> <%= f.input :taxes %> <%= f.input :house_families %> <%= f.input :house_extensions %> <%= f.input :house_stories %> <%= f.input :house_units %> </div> <div style="display: none;" data-show-for-prop-type="Condo"> <h4>Condo</h4> <%= f.input :taxes %> <%= f.input :common_charges %> </div> 

listings.js file:

 $('#listing_property_type_id').on('change', function(){ var option = $(this).find(':selected'); $('[data-show-for-prop-type]').hide(); //And maybe reset? $('[data-show-for-prop-type='+ option.text() +']').show(); }); 
0
source share
1 answer

See some JS errors on realty-cloud.herokuapp.com/listings/new ... "Unprepared TypeError: Unable to read property" oApi "from undefined". Almost positively that could be a problem.

The reason Dev had a problem is because they were separate assets in dev, so the error was limited to one js file with this error. However, since the asset pipeline is compiled into one, errors stop the rest of its execution.

The best bet is to fix all console errors or add "undefined" to prevent such "Uncaugh TypeError" errors.

+1
source

All Articles