简体   繁体   English

jQuery气球

[英]jQuery balloons

Does anyone know if you can use a jQuery balloon on a text input that is contained on a jQuery modal dialog? 有谁知道您是否可以在jQuery模式对话框中包含的文本输入上使用jQuery气球?

<div id="dlg-clock_in_out">
  <section class="roundbox-sml" style="padding:5px; 5px;">
    <input type="hidden" name="empid" id="empid" value="" />
    <div style="width:100%; text-align:center;">
      <label for="pin">PIN: </label><input type="password" name="pin" id="pin" maxlength="4" size="5" value="" />
    </div>
    <div id="login-btns-wrapper">
      <input type="button" id="loginSubmit" class="buttons roundbox-sml" value="<?=$btn_text?>" />
      <input type="button" class="buttons roundbox-sml" name="loginCancel" id="loginCancel" value="Cancel" />
    </div>
  </section>
</div>

<script type="text/javascript">
  $('#pin').keypress(function(e) {
    if(check_pin_chars(String.fromCharCode(e.which))) {
      $(this).val('');
      $(this).balloon({
        position     : "top right",
        showDuration : 125,
        minLifetime  : 2000,
        tipSize      : 4
     });

     $(this).showBalloon();
   }
});

And the jquery I want to use when this modal dialog is shown is supposed to put a balloon next to the input field, but I don't know if a balloon can exist on an element residing in a jquery modal dialog. 我想在显示此模式对话框时使用的jQuery应该在输入字段旁边放置一个气球,但我不知道气球是否可以存在于驻留在jQuery模式对话框中的元素上。

Does anyone know if this is possible? 有人知道这是否可能吗? I know how to do it for a standard form input element. 我知道如何针对标准表单输入元素执行此操作。 It's just not showing up on my modal dialog. 它只是没有显示在我的模式对话框中。

Here's what I'm attempting to use to accomplish this. 这就是我试图用来完成此任务的方法。 http://file.urin.take-uma.net/jquery.balloon.js-Demo.html http://file.urin.take-uma.net/jquery.balloon.js-Demo.html

Thanks. 谢谢。

Your problem may be that you haven't properly set the z-index of the balloon to be higher than your the modal dialog. 您的问题可能是您没有正确将零件序号的Z索引设置为高于模态对话框。

$('.balloon').css('z-index','9999');

It may also be an option with your JavaScript (I don't know if you are using a library you wrote or one you found elsewhere): 您的JavaScript也可能是一个选项(我不知道您使用的是您编写的库还是在其他地方找到的库):

$(this).balloon({
    position     : "top right",
    showDuration : 125,
    minLifetime  : 2000,
    tipSize      : 4,
    z-index      : 9999
 });

Update Based on Feedback 根据反馈更新

I was pretty close to right with my answer. 我的回答非常接近正确。 There are actually two issues with your code and why you are not seeing a balloon. 您的代码实际上有两个问题,以及为什么看不到提示框。

First, I was right about the z-index. 首先,我对z-index的看法是正确的。 However, you have to set the z-index in the CSS, not directly in the balloon options. 但是,您必须在CSS中设置z-index,而不是直接在气球选项中设置。 So, in your case, it would be: 因此,在您的情况下,它将是:

#pin {
 z-index: 99999
}

However, the other problem that you have comes from your default options. 但是,另一个问题来自默认选项。 Here is the key wording in the documentation on the jquery.balloon.js site: 这是jquery.balloon.js站点上的文档中的关键词:

Default contents of balloon is its title. 气球的默认内容为其标题。 If the element has no title, balloon is not created. 如果元素没有标题,则不会创建气球。

Because you didn't provide content in your options, you won't see any balloon because there is nothing it can display. 由于您未在选项中提供内容,因此您将看不到任何气球,因为它无法显示。 So, since you are displaying it with respect to your pin password box, you have to add either a content option, or add a title to your password box. 因此,由于您是根据密码密码框进行显示的,因此您必须添加一个内容选项,或在密码框中添加标题。 Something like this: 像这样:

<input type="password" name="pin" id="pin" maxlength="4" size="5" value="" title="Correct Pin!" />

I created a little demo on jsfiddle to show how everything comes together. 在jsfiddle上创建了一个小样的演示 ,展示了一切如何结合在一起。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM