複数の入力フィールドを持つポップアップがいくつかあります。すべてのポップアップの FIRSTinput 要素を強調表示したいのですが、ID を使用したくありません。
私のコード:
function initPopups(){
$('*[id*=Popup]').each(function() {
$(this).on({
// disables the auto close on outer clicks
popupbeforeposition: function () {
// removes all handlers from the 'background'(-layer.class) of the popup
$('.ui-popup-screen').off();
},
// SHOULD highlight the first textfield after popup opened
popupafteropen:function(){
console.log("OPENED");
$('form:first *:input[type!=hidden]:first').focus();
}
});
});
1 つのポップアップの html を次に示します。
<div data-role="popup" id="create_stationPopup" class="ui-content">
<a href="#" data-rel="back" data-role="button" data-theme="c" data-icon="delete" data-iconpos="notext"
class="ui-btn-right">Close</a>
<form>
<input type="text" name="name" id="station_input_title" value="" data-mini="true" placeholder="Titel der Station" />
<input type="text" name="name" id="station_input_number" value="" data-mini="true" placeholder="Nummer der Station"/>
<textarea name="textarea" id="station_input_text" placeholder="Beschreibe diese Station"></textarea>
</form>
<a href="#create_stationQuestionPopup" data-rel="popup" data-role="button" data-theme="c" id="createWave_questionBtn" >Frage
hinzufügen</a>
<a id="createWave_stationSaveBtn" data-role="button" data-theme="c">Station
speichern</a>
</div>
私のコードは、HTML ファイルの最初の入力フィールドのみを強調表示し、すべてのポップアップ (静的 html にある) の最初の入力フィールドは強調表示しません。