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

查看:131
本文介绍了修改“选项". 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参数以影响弹出窗口的位置. 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事件忽略了一个对象,该对象包含弹出窗口的位置(选项),xypositionTo的值.

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
});

值=像素数

演示

Demo

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

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