jQuery Mobile-在显示页面之前调整表单元素的大小 [英] JQuery Mobile - Resize Form Elements Before Displaying Page

查看:90
本文介绍了jQuery Mobile-在显示页面之前调整表单元素的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在调整JQM控制按钮组的大小以适合其内部包含的DIV的宽度.

I'm resizing a JQM control button group to fit the width of the DIV its contained inside.

但是,我想在用户看到任何东西之前执行此操作.目前,我只能在页面显示后才能执行此工作,这就像故障一样.

However, I want to do this before the user sees anything. Currently, I can only make this work after the page has displayed, which works like a glitch.

这是我的大小调整代码:

Here is my resize code:

var myWidth = $(window).width() - 1.3*($(window).width() - $('#eventForm').width());
$('.eStatusLabel').css("width", myWidth/3);

以下是我尝试用来触发的函数,但#eventForm宽度始终为0:

Here are the functions I have tried to use to triger this, but the #eventForm width is always 0:

$("#myPage").live('pageinit',function(){ //Resize});
$("#myPage").live('pageload',function(){ //Resize});
$("#myPage").live('pagebeforeshow',function(){ //Resize});

有没有一种方法可以在显示之前获取表单的大小?是否有另一种方法可以获取内容页面的内部宽度,而无需包含data-role ="page"填充?

Is there a way to grab the size of the form before displaying? Is there another way to get the inner width of the content page without the data-role="page" padding included?

谢谢

推荐答案

唯一可行的方法是重写默认的jquery-mobile css.您可以在页面加载后为父元素分配ID和ID,并定义宽度和其他属性,并在页面加载后以ID开头.这个概念就像通过ajax加载html内容,然后将css应用于该html.

The only way possible to do this is by overriding the default jquery-mobile css. You can assign and id to the parent element after your page loads and define the width and other properties preceded by the id you are getting after the page loads. The concept is just like loading an html content through ajax and the css gets applied to that html.

这篇关于jQuery Mobile-在显示页面之前调整表单元素的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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