在jqueery插件中附加大量HTML [英] Appendiing a large chunk of HTML in a jqueery plugin
问题描述
更多最佳实践问题。
我正在创建一个jquery插件,我想在面板的面板中添加相当多的html - 身体部分。我已经使用它了;
More of a best practices question.
I'm creating a jquery plugin and I want to append a fairly large amount of html into a panel in the panel-body section. I've got it working by using;
var res = '<div><input type="text" data-action="calc_1" /></div>';
$(this).each(function (e) {
$(this.element).find('.panel-body').append(res);
$(this.element).on('keyup', this.someOtherFunction);
});
它按设计工作但html只有我想要附加的部分,我只是想知道;有没有比我做的更好的方式。
我尝试了什么:
我想过使用javascript tamplates但很快意识到脚本不会包含在插件中。
and it is working as designed but the html there is only a portion of what I want to append and I'm just wondering; is there a better way then the way I'm doing it.
What I have tried:
I thought about using javascript tamplates but quickly realized that the script would not be contained within the plugin.
推荐答案
( this )。each( function (e){
(this).each(function (e) {
( this .element).find(' 。panel-body')。append(res);
(this.element).find('.panel-body').append(res);
( this .element).on(' keyup', this .someOtherFunction);
});
(this.element).on('keyup', this.someOtherFunction); });
它按设计工作但html只有我要追加的部分内容而我只是想知道;有没有比我做的更好的方式。
我尝试了什么:
我想过使用javascript tamplates但很快意识到该脚本不会包含在插件中。
and it is working as designed but the html there is only a portion of what I want to append and I'm just wondering; is there a better way then the way I'm doing it.
What I have tried:
I thought about using javascript tamplates but quickly realized that the script would not be contained within the plugin.
这篇关于在jqueery插件中附加大量HTML的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!