jQuery单击事件未按预期工作

时间:2014-05-09 10:23:37

标签: jquery ios iphone

除了IOS之外,以下所有主要设备都可以使用以下脚本:

$(document).on("click", "#frmRoomSelector section[id^=roomDetails_] div.addRoomWrapperDynamic", {
    rooms: HB.roomOptions,
    captions: HB.roomPricingCaptions,
    roomSelector: HB.oRoomSelector,
    listItemTemplate: listItemTemplate
}, function(event) {
    var data = event.data,
        element = $(this).parent().parent(),
        modalElement = $(".modal"),
        elementId = element.attr("id"),
        id = elementId.split("_")[1],
        mealPlan = $(".meal-plan", element).html(),
        roomType = element.data("isprivate") ? "private" : "shared",
        roomOptions = data.rooms[id];
    data.roomSelector.selectedRoomId = id;
    if (mealPlan !== undefined) {
        mealPlan = mealPlan.trim();
    }
    HB.RoomSelector.populateModalTemplate(modalElement, {
        name: $(".roomName", element).html(),
        price: $(".roomPrice", element).html(),
        mealPlan: mealPlan,
        caption: data.captions[roomType]
    });

    var options = [],
        listItem = data.listItemTemplate.cloneNode(true);   // Fresh copy of the template
    for (var i = 0; i < roomOptions.length; i++) {
        HB.RoomSelector.populateItemTemplate(listItem, {
            roomId: "select_" + elementId + "_" + i,
            bedsTotal: roomOptions[i].BEDS,
            units: roomOptions[i].UNITS,
            selectedOption: HB.RoomSelector.getBedsToBookValueById(id)
        });
        options.push(listItem.outerHTML);
    }
    $("#modal-room-selector ul", modalElement).html( options.join("") );    // This could be cached

    modalElement.modal();
});

这是唯一适用于它的样式:

.addRoomWrapperDynamic,
.addRoomWrapperStatic{
    float: right;
    width: 64px;
    text-align: center;
    height: 101px;
    padding-top: 20px;
    margin-top: -1px;
}

.addRoomWrapperDynamic{
    background-color: #70a6df;
}

,HTML是:

<div class="extraRoomInfo">
    <span class="roomPrice<cfif len(stuViewVars.rstPropertyRooms.price) GT stuViewVars.longPriceThreshold> longPrice</cfif>">#stuViewVars.oLocaleCurrency.formatCurrency(fltPrice = stuViewVars.pricePerUnit, strCurrencyCode = uCase(stuViewVars.strCurrencyCode))#</span>
<input type="hidden" name="intRoomId_#stuViewVars.rstPropertyRooms.RoomID#" value="#stuViewVars.rstPropertyRooms.RoomID#" />
<input type="hidden" name="isPrivate_#stuViewVars.rstPropertyRooms.RoomID#" value="#stuViewVars.rstPropertyRooms.isPrivate#" />
<input type="hidden" name="intBedsToBook_#stuViewVars.rstPropertyRooms.RoomID#" value="0" id="intBedsToBook_#stuViewVars.rstPropertyRooms.RoomID#" />
    <div class="addRoomWrapperDynamic">

            <span class="icon-plus2"></span>
            <span class="addRoomText">
                <cfif stuViewVars.rstPropertyRooms.isPrivate>add rooms<cfelse>add beds</cfif>
            </span>

    </div>
</div>

点击&#39; addRoomWrapperDynamic&#39;一个boostrap模态淡入,它可以在任何地方工作,但当你点击ios设备时没有任何反应。

1 个答案:

答案 0 :(得分:1)

document.addEventListener('touchstart', function(e) { 

}, false);