修改“选项"popupbeforeposition 事件的参数 [英] Modify the "options" parameter of popupbeforeposition event

查看:20
本文介绍了修改“选项"popupbeforeposition 事件的参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jQuery Mobile 库(版本 1.3.1)的 Popup 小部件.我正在尝试处理 beforeposition 事件中的一些代码.文档 说:

I am using the Popup widget of the jQuery Mobile library (version 1.3.1). I am trying to handle some code in the beforeposition event. The documentation says that:

处理此事件可以在弹出窗口出现在屏幕上之前对其内容进行修改.例如,如果内容太宽或太高,可以缩放内容或隐藏或删除部分内容.您还可以修改选项参数以影响弹出窗口的位置.options 对象内部可修改的属性与 reposition 方法使用的属性相同.

Handling this event gives an opportunity to modify the content of the popup before it appears on the screen. For example, the content can be scaled or parts of it can be hidden or removed if it is too wide or too tall. You can also modify the options parameter to affect the popup's placement. The properties inside the options object available for modification are the same as those used by the reposition method.

我需要设置 xy 参数,但我不知道如何修改事件的 options 参数.一个代码示例会很棒.感谢您的宝贵时间.

I need to set the x and y parameters but I could not figure out how to modify the options parameter of the event. A code example would be awesome. Thanks for your time.

推荐答案

beforeposition 事件省略包含弹出窗口位置(选项)、x 值的对象ypositionTo.

beforeposition events omits an object containing values of popup's position (options), x, y and positionTo.

要在 beforeposition 触发后修改这些选项,请使用以下内容.

To modify those options once beforeposition triggers, use the below.

$( ".selector" ).on( "popupbeforeposition" , function (e, ui) {
    ui.x = value;
    ui.y = value;
    /* OR
    ui.positionTo = "window"
    */
});

如果您希望以编程方式打开弹出窗口,请使用以下内容.

If you wish to open a popup programmatically, use the below.

$( ".selector" ).popup( "open", {
  x: value,
  y: value
});

值 = 像素数

演示

这篇关于修改“选项"popupbeforeposition 事件的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆