选择值返回错误值

时间:2018-05-04 14:02:57

标签: javascript jquery typescript

我在我的视图中选择

这是代码

 <li class="airline">
      <select name="search[airline]" id="search_airline" class="custom" style="display: none;">
          <option value="">Alla</option>
          <option value="SK">SAS</option>
          <option value="DY">Norwegian</option>
          <option value="EI">Aer Lingus</option>
          <option value="SU">Aeroflot</option>
          <option value="AR">Aerolineas Argentinas</option>
          <option value="AM">Aeromexico</option>
          <option value="BT">Air Baltic</option>
          <option value="AC">Air Canada</option>
          <option value="CA">Air China</option>
          <option value="UX">Air Europa</option>
          <option value="AF">Air France</option>
          <option value="AI">Air India</option>
          <option value="NZ">Air New Zealand</option>
          <option value="AZ">Alitalia</option>
          <option value="NH">All Nippon Airways</option>
          <option value="AA">American Airlines</option>
          <option value="OS">Austrian Airlines</option>
          <option value="VO">Austrian Arrows</option>
          <option value="BA">British Airways</option>
          <option value="BD">British Midland</option>
          <option value="SN">Brussels Airlines</option>
          <option value="CX">Cathay Pacific</option>
          <option value="CO">Continental Airlines</option>
          <option value="OK">Czech Airlines</option>
          <option value="DL">Delta Airlines</option>
          <option value="EK">Emirates</option>
          <option value="EY">Etihad Airways</option>
          <option value="AY">Finnair</option>
          <option value="GA">Garuda Indonesia</option>
          <option value="IB">Iberia</option>
          <option value="FI">Icelandair</option>
          <option value="KL">KLM</option>
          <option value="KE">Korean Air Lines</option>
          <option value="LA">LAN Airlines</option>
          <option value="LO">LOT - Polish Airlines</option>
          <option value="NG">Lauda Air</option>
          <option value="LH">Lufthansa</option>
          <option value="DM">Maersk Air</option>
          <option value="MH">Malaysian Airlines</option>
          <option value="TF">Malmö Aviation</option>
          <option value="MX">Mexicana Airlines</option>
          <option value="NW">Northwest Airlines</option>
          <option value="DY">Norwegian</option>
          <option value="OA">Olympic Airways</option>
          <option value="QF">Qantas Airways</option>
          <option value="QR">Qatar Airways</option>
          <option value="SK">SAS</option>
          <option value="SQ">Singapore Airlines</option>
          <option value="SA">South African Airways</option>
          <option value="LX">Swiss Intl Air Lines</option>
          <option value="TP">TAP Portugal</option>
          <option value="TG">Thai Airways</option>
          <option value="TK">Turkish Airlines</option>
          <option value="UA">United Airlines</option>
          <option value="VS">Virgin Atlantic Airw.</option>
          <option value="VY">Vueling</option>
          <option value="WF">Wideroe</option>
      </select>
      <span tabindex="0" id="search_airline-button" role="combobox" aria-expanded="false" aria-autocomplete="list" aria-owns="search_airline-menu" aria-haspopup="true" class="ui-selectmenu-button ui-selectmenu-button-closed ui-corner-all ui-button ui-widget"><span class="ui-selectmenu-icon ui-icon ui-icon-triangle-1-s"></span>
          <span class="ui-selectmenu-text">Flygbolag: Alla</span>
      </span>
 </li>

此外,我在TS中具有使用word生成变量的功能 - &#34; Flygbolag&#34;

这是

function update_search_airline() {
    $(".ui-selectmenu-text", $("#search_airline-button")).html(
  __("Flygbolag") + ": " + $(".ui-selectmenu-text", $("#search_airline-button")).html());
}

因此,当我加载页面一切正常时,我得到了例如

enter image description here

但是当我从这个选择中选择值时,我也需要使用这个词

所以在函数中我创建了这段代码

function load_field_actions(): void {
  $(".tooltip").tooltipster()
  $("#search_airline").change(update_search_airline)
}

此行必须正确更新

  

$(&#34;#search_airline&#34)。变化(update_search_airline)

但它只是在没有Flygbolag的情况下将默认值更改为下一个值

0 个答案:

没有答案