简体   繁体   English

动态创建模式页面

[英]Create modal page dynamically

I have a conceptual question, when i want create a modal in my page, always include the html of my modal in the page, something like this : 我有一个概念性的问题,当我想在页面中创建模态时,请始终在页面中包含模态的html ,如下所示:

<div class="my-modal">
 <form action="/home/index">
  <input type="text" class="txt-name"/>
  <input type="text" class="txt-last-name"/>
  <input type="submit" value="register!"/>
 </form>
</div>

Usually i show this modal by jquery plugins, like blockUI and etc. Now i have some questions in my mind and i want to do the best: 通常,我通过jquery插件(例如blockUI等)来显示此模式。现在我心中有一些疑问,我想做到最好:

  • Always i should include this section in my html page, but maybe the user doesn't need to using this, maybe he need another sections but i use the memory. 总是我应该在我的html页面中包括此部分,但也许用户不需要使用它,也许他需要其他部分,但是我使用了内存。
  • When using this modal form, always i need to reset or re-initial my modal form and it's so boring to doing this stuff when i have multiple modals in the page. 使用这种模式形式时,总是需要重置或重新初始化我的模式形式,而当我在页面中有多个模式时,这样做很无聊。

So i need a technique, plugin or etc. to handle these issues. 所以我需要一种技术,插件等来解决这些问题。 Any idea for this? 有什么想法吗?

UPDATE 更新

After some searches i think should use some libraries like requirejs , but i don't know how... 经过一些搜索,我认为应该使用诸如requirejs库,但是我不知道如何...

RequireJS would load the template ondemand, but not the markup! RequireJS将按需加载模板,但不会加载标记!

Take an eyes to this: 注意一下:

Angular > ng-if > custom directives (transclude: true) Angular> ng-if>自定义指令(包含:true)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM