JQuery Facebox Plugin : Get it inside the form tag

做~自己de王妃 提交于 2019-11-29 08:06:15
Kevin Sheffield

poking around the facebox.js I came across this line in the function init(settings)...

$('body').append($.facebox.settings.faceboxHtml)

I changed that to ...

$('#aspnetForm').append($.facebox.settings.faceboxHtml)

and it loads up in the form tag, not sure yet if there are any side effects

You can use this code to register the PostBack event:

btn.OnClientClick = string.Format("{0}; $.facebox.close();",ClientScript.GetPostBackEventReference(btn, null));

this will let the button fires a PostBack.

Even after the : $('#aspnetForm').append($.facebox.settings.faceboxHtml)

change I found it problematic. When you look at the page source using firebug you see that all the html in the div assigned to be the facebox div is doubled up (repeated).

So all of those controls with supposed unique id's are doubled up on the page, that can't be good on the postback, i've decided putting asp.net web controls in a facebox is not a good idea.

I modified facbox.js to do this. Maybe there is a better solution but this works like a charm

Here what i did:

  1. add two lines on top of facbox.js before '(function($)'
var willremove = '';
var willremovehtml = '';
  1. find "reveal: function(data, klass) {" and add this lines before the first line of function.
willremove = data.attr('id')
willremovehtml = $('#'+willremove).html()
$('#'+willremove).html('')
  1. find "close: function() {" and make it look like below.
close: function() {
$(document).trigger('close.facebox')
$('#'+willremove).html(willremovehtml)
willremovehtml = ''
willremove = ''
return false
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!