2

我在平板电脑上的单选框上获得了多次点击,在桌面上一切正常,但在平板电脑上,selectCompany 被调用了两次,平板电脑上的点击是否有问题?

这是代码:

<div class="formcontent" id="formContent">
    <div data-role="fieldcontain" id="companyContainer" class="ui-field-contain ui-body ui-br">
        <fieldset data-role="controlgroup" class="ui-corner-all ui-controlgroup ui-controlgroup-vertical">
            <div role="heading" class="ui-controlgroup-label">Empresa:</div>
            <div class="ui-controlgroup-controls">
                <div class="ui-radio">
                    <input type="radio" onclick="selectCompany(1)" name="company_select" id="company_select_0" value="0">
                    <label for="company_select_0" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="radio-off" data-theme="c" class="ui-btn ui-btn-icon-left ui-corner-top ui-btn-up-c ui-radio-off"><span class="ui-btn-inner ui-corner-top"><span class="ui-btn-text">Google</span><span class="ui-icon ui-icon-shadow ui-icon-radio-off">&nbsp;</span></span>
                    </label>
                </div>
                <div class="ui-radio">
                    <input type="radio" onclick="selectCompany(2)" name="company_select" id="company_select_1" value="1">
                    <label for="company_select_1" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="radio-off" data-theme="c" class="ui-btn ui-btn-icon-left ui-radio-off ui-btn-up-c"><span class="ui-btn-inner"><span class="ui-btn-text">Amazon</span><span class="ui-icon ui-icon-shadow ui-icon-radio-off">&nbsp;</span></span>
                    </label>
                </div>
                <div class="ui-radio">
                    <input type="radio" onclick="selectCompany(4)" name="company_select" id="company_select_2" value="2">
                    <label for="company_select_2" data-corners="true" data-shadow="false" data-iconshadow="true" data-wrapperels="span" data-icon="radio-off" data-theme="c" class="ui-btn ui-btn-icon-left ui-corner-bottom ui-controlgroup-last ui-radio-on ui-btn-up-c"><span class="ui-btn-inner ui-corner-bottom ui-controlgroup-last"><span class="ui-btn-text">Apple</span><span class="ui-icon ui-icon-shadow ui-icon-radio-on">&nbsp;</span></span>
                    </label>
                </div>
            </div>
        </fieldset>
    </div>
</div>
4

2 回答 2

2

我会检查这个问题。基本上,似乎点击事件正在触发几个触摸事件。也许检测浏览器(即如果在平板电脑上)并以不同的方式处理绑定将解决您的问题。

于 2012-09-24T18:37:27.803 回答
0

我所做的是取消绑定变量...

$("#foodiv").bind("click", function( event ) {
  functionCalledOnce();
  $(this).unbind( event );
});

它很干净,效果很好。

于 2012-10-26T11:25:20.287 回答