RailsCasts Pro episodes are now free!

Learn more or hide this

John Harper's Profile

GitHub User: jhnhrpr

Site: http://johnharper.me

Comments by John Harper

Avatar

It appears that this was an issue with console.log, which I now realize wasn't intended to be in the final version of the code. When IE's "F12 Developer Tools" feature was enabled, the dynamic select menus worked as intended. I removed both instances of console.log from the coffeescript file and the issue is gone, with and without F12 Developer Tools enabled. Gotcha on me.

More on this here: http://stackoverflow.com/questions/11346091/i-e-craches-my-js-script-at-first-then-i-press-f12-and-it-works-beaultifully?lq=1

Avatar

And the html...

html
<div class="row" id="preferred_performance_row">
  <select id="order_preferred_performance_id" name="p">
    <option value=""></option>
    <option value="1">Friday, 11/23/2012 -  2:00 pm</option>
    <option value="2">Friday, 11/23/2012 -  5:30 pm</option>
  </select>
</div>
<div id="preferred_ticket_level_row">
  <select id="order_preferred_ticket_level_id" name="tl">
    <option value=""></option>
    <optgroup label="Friday, 11/23/2012 -  2:00 pm">
      <option value="1">Orch 1 - $66.00</option>
      <option value="2">Orch 2 - $46.00</option>
    </optgroup>
    <optgroup label="Friday, 11/23/2012 -  5:30 pm">
      <option value="3">Orch 1 - $66.00</option>
      <option value="4">Orch 2 - $46.00</option>
    </optgroup>
  </select>
</div>
Avatar

This isn't working for me in Internet Explorer 9...Changing the first select menu doesn't do anything. The second select menu remains hidden.

Chrome on Windows, and Safari, Firefox, and Chrome on OS X work fine. Any gotchas that you've found?

coffees.js
jQuery ->
  loaded_ticket_level = $('#order_preferred_ticket_level_id :selected').text()
  if loaded_ticket_level.length < 1
    $('#preferred_ticket_level_row').hide()
  
  ticket_levels = $('#order_preferred_ticket_level_id').html()

  console.log(ticket_levels)
  $('#order_preferred_performance_id').change ->
    performance = $('#order_preferred_performance_id :selected').text()
    escaped_performance = performance.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1')
    options = $(ticket_levels).filter("optgroup[label=#{escaped_performance}]").html()
    console.log(options)
    if options
      $('#order_preferred_ticket_level_id').html(options)
      $('#preferred_ticket_level_row').slideDown("fast")
    else
      $('#order_preferred_ticket_level_id').empty()
      $('#preferred_ticket_level_row').hide()