创建多个功能
Creating Multiple Functions
我尽量把这个问题讲清楚。
我要做的是:
元素:——按钮-模态盒——功能
应用程序要求:
- 我需要在一个页面上有一个按钮,当点击它调用一个函数称为
newcontent
。该函数需要有自己的函数唯一的ID,因为我有一个特定的pageID显示在模态框 - 在模态框函数中,我用一个特定的ID,但我也使用.each函数来获取特定的DIV ID
下面是当前的模态框代码:
function newcontent() {
$('div.heriyah').each(function() {
$.fallr('show', {
content : '<iframe width=620" height="600" src="<? echo $URL ?>/manage_content.php?id=<? echo $pageID; ?>&div='+ this.id +'"></iframe>',
width : 620 + 5, // 100 = for width padding
height : 600,
closeKey : true,
closeOverlay : true,
buttons : {}
});
});
}
我将得到如下错误:
uncaught exception: Can't create new message with content: "<iframe
width=620" height="600"
src="http://www.brandonrray.com/Heriyah/admin/manage_content.php?id=1&div=sermons_home"></iframe>",
past message with content "<iframe width=620" height="600"
src="http://www.brandonrray.com/Heriyah/admin/manage_content.php?id=1&div=up_events_home"></iframe>"
is still active
但我知道这是因为我试图调用相同的函数,如10次,这取决于页面上有多少div。
Button Jquery Wiring:
$('div.heriyah').each(function() {
$('div.heriyah').append('<div id="add_button_container"><a onClick=newcontent_'+ this.id +'();return false><div id="add_button" class="edit_links">+ ADD NEW CONTENT</div></a></div></div><div class="clear"></div><div class="placeable"></div>');
});
谁能把我在正确的方向为这个应用程序,如果你需要我更清楚,请让我知道。我不想再被踢出这些论坛!
不是每次单击按钮时应用each
,而是使用回调函数并使用存储在按钮元素中的参数触发newContent。参数也可以是按钮的任何属性。
$('button[class=yours]').click(function () {newContent(this.id)});
// If you want to pass the DIV ID from the button
// $('button[class=yours]').click(function () {newContent($(this).attr('div-id')});
//
var newContent = function (uniqueId) {
$.fallr('show', {
content : '<iframe width=620" height="600" src="<? echo $URL ?>/manage_content.php?id=<? echo $pageID; ?>&div='+ uniqueId +'"></iframe>',
width : 620 + 5, // 100 = for width padding
height : 600,
closeKey : true,
closeOverlay : true,
buttons : {}
});
};
相关文章:
- 如何使用Java脚本创建提交按钮's的拖放功能
- 使用Jquery创建一个具有单击和悬停功能的菜单
- 创建缩放功能当我们点击签署整个页面获得缩放,当我们点击-签署它获得缩小
- .on(“单击”,..)不处理使用相同的单击功能创建的对象
- 我使用什么语言来创建像Webly这样的拖放功能
- 在Google AdWords中创建可重用功能
- 有没有一种方法可以修改在使用javascript的媒体功能的媒体查询下创建的样式
- 创建具有点击幻灯片功能的 jQuery 滑块
- 如何创建一个脚本,该脚本给定网站列表,它使用其搜索功能来获取信息
- 创建具有蓝鸟承诺的节流功能
- Javascript在不同的功能中创建Cookie
- 具有动态幻灯片创建功能的JavaScript滑块
- 按钮创建无法定位功能代码错误
- 从文件目录结构创建JSON数据的有效功能
- 如何创建具有合并和调整大小功能的表
- 在PhpStorm中创建自定义语言,扩展所有html语言功能
- 创建通用控制器功能
- 创建可在任何地方使用的 JS 函数?范围和功能“未定义”的问题
- 创建高图表点击功能时丢失了 Angularjs 范围
- 如何在WinJS中为列表视图创建排序功能