当前位置: 动力学知识库 > 问答 > 编程问答 >

How to use variables in modal function's position option in SimpleModal 1.4.4

问题描述:

I am having an issue inserting variables into the modal functions position option. The following works:

 $.modal('<iframe id = "framedetails" src="' + src + '" height="' + vHeight + 'px;" width="' + vWidth + 'px;" style="border:0"></iframe>', {

closeHTML:"<a href='#' class='modalCloseImg' alt='Close/Cancel' title='Close/Cancel'><a>", //add close button

fixed: false,

position: ["75px","595.5px"],

overlayClose:false

});

How would I insert a variable for each of the position values? I am unable to get the concatenation correct and have tried many variations.

For example, position: ["" + vTop + "","" + vLeft + ""] seems to insert the value for vTop but the vLeft variable is not being applied. If I supply the actual value in this for vLeft, it works as expected. What am I missing here?

网友答案:

I figured this out...pretty silly of me. I just create a string array of the two variables (vTop and vLeft) and passed them in.

vArray = ["" + vTop + "","" + vLeft + ""];    

... position: vArray

分享给朋友:
您可能感兴趣的文章:
随机阅读: