Problem Description
There is a relatively complex HTML fragment (A). If this HTML fragment is embedded into other pages (B, C, D...).
The key to the problem is that there is a lot of JavaScript logic that needs to be processed in the HTML fragment, such as paging, click event response, etc.
For this problem, we use a simple example to illustrate:
"There is a button on the page. Click this button to introduce an HTML fragment. There is a paging button in this HTML fragment."
1. Use IFrame
main page, click a button to introduce an IFrame to the page:
3. AJAX返回页面片段,并调用页面片段中的函数注册事件
4. AJAX返回页面片段,其事件自动注册