- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
<分区>
我在替换 javascript/jquery 中的字符串时遇到了一点问题。首先是代码:
HTML:
<fieldset>
<legend>Contact persons</legend>
<div id="cm_contactPersons">
<fieldset id="cm_%email%">
<legend><span class="glyphicon glyphicon-circle-arrow-right"></span> %email%</legend>
<div class="form-group">
<label for="cm_%email_inputFirstname" class="col-sm-2 control-label">Firstname</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="cm_%email%_inputFirstname" value="%firstname%" placeholder="" required>
</div>
</div>
<div class="form-group">
<label for="cm_%email%_inputLastname" class="col-sm-2 control-label">Lastname</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="cm_%email%_inputLastname" value="%lastname%" placeholder="i. e. Max" required>
</div>
</div>
<div class="form-group">
<label class="col-sm-2 control-label">Actions</label>
<div class="col-sm-10">
<button type="button" class="btn btn-warning">Create new password</button>
<button type="button" class="btn btn-danger">Delete contact person</button>
</div>
</div>
</fieldset>
</div>
</fieldset>
Javascript:
$(document).ready(function() {
$('#cm_customerList').btsListFilter('#cm_customerSearchInput');
var editingArea = $('#cm_editingArea');
var contactPersons = $('#cm_contactPersons');
var contactPersonsTpl = contactPersons.html();
var alertArea = $('#cm_alertArea');
$('#cm_customerList > a').each(function() {
$(this).click(function(e) {
e.preventDefault();
$('#cm_customerList>a.active').removeClass('active');
$(this).addClass('active', 400);
$('html').animate({
scrollTop: 0
});
alertArea.fadeOut(400, function() {
alertArea.empty();
});
$.ajax({
type: 'GET',
url: 'index.php?' + $(this).attr('data-ajaxUrl'),
success: function(data) {
res = $.parseJSON(data);
editingArea.fadeOut(400, function() {
$('#cm_inputName').val(res.name);
$('#cm_inputStreet').val(res.street);
$('#cm_inputPostalcode').val(res.postalcode);
$('#cm_inputCity').val(res.city);
$('#cm_inputCountry option[value="' + res.country + '"]').prop('selected', true);
$('#cm_inputCountry').select2({
width: '100%'
});
$('#cm_inputTutors option:selected').prop('selected', false);
$.each(res.tutors, function(key, tutor) {
$('#cm_inputTutors option[value="' + tutor.username + '"]').prop('selected', true);
});
$('#cm_inputTutors').select2({
width: '100%'
});
contactPersons.empty();
$.each(res.contactpeople, function(key, contactPerson) {
contactPersons.append(contactPersonsTpl.replace('%email%', contactPerson));
});
editingArea.fadeIn();
});
},
error: function(xhr, ajaxOptions, thrownError) {
//error handler
}
});
});
});
});
带有“contactPersons.append(contactPersonsTpl.replace('%email%', contactPerson));
”的部分替换根本不起作用。我尝试了所有各种类型的调试(日志、更改 substr 等)。没有机会。
但是如果我在 Firefox 控制台中写入“$('#cm_contactPersons').html().replace('%email%', 'test@blubb.at');
”,有用。
我做错了什么?
我正在从一个旧数据库中选择数据,该数据库有一个滥用状态列。状态列中包含多条信息。值如“新联系人 YYYY”、“在线 YYYY”、“更新 YYYY”、“撤回 YYYY”等……。您可能已经猜到了,YYYY
我想使用ant的replace任务替换这样的文件之一中的 token : 版本.txt version.number=${versionNumber} build.gradle task writeV
sorted_elems 列表中有一些元素将被更改为 str 例如: sorted_elems = ['[abc]', '[xyz]', ['qwe']] 我想删除定义的字符 - [, ], ' 并打
如果替换在变量中传递,第一次和第二次替换是否等效? #!/usr/bin/env perl6 use v6; my $foo = 'switch'; my $t1 = my $t2 = my $t3
我正在做一个本地测试来比较 C# 中 String 和 StringBuilder 的 Replace 操作性能,但是对于 String 我使用了以下代码: String str = "String
我看到了所有内容,没有看到使用“--replace”的方式的内容。 如何在 wkhtmltopdf 中使用“--replace”。 请给我一个例子,谢谢。:) 最佳答案 假设您有一个页脚 my_foo
我需要在 50 多个文件中进行大量搜索/替换,并且正在使用 Sublime Text 3。 有没有办法逐步执行并交互确认每个更改?我不想要只执行所有替换的一揽子“全部替换”操作。 我正在思考 vi/v
那么“replace ”属性如何与 composer 一起使用? ?我已经阅读了 Composer 文档,但仍然不明白。搜索更多信息并没有回答我的问题。 当我查看Laravel/Framework上的
我在玩 F# 句法。 在瑞典,我们有一个游戏叫做“Backslang”(谷歌翻译自“Rövarspråk”) 规则很简单。你说的所有话都必须以特定的方式说出来。虽然人声是相同的,但每个辅音都必须用“o
是否可以在Atom或Sublime Text中对“item”一词使用“查找和替换”并将其替换为“item [i]”,其中[i]是从1开始的数字? 我有一堆看起来像这样的物品: item1 item1
我不太确定如何解释,所以我将从输出开始。我需要返回这个: { replies: [ { type: 'text', content: 'one' } { type:
我是 C# 的新手,所以请原谅我的错误。 我想在每次调用该段代码时(每次调用 2-4 次)替换字符串的某些部分。我想知道哪种方法在性能方面更好:string.Replace 或 stringBuild
我了解.Replace() 和-replace 之间的区别,但是什么是-replace 和[Regex]: :替换()? 我测试了以下 2 个代码,但对我来说结果完全一样。 我还引用了 PowerSh
如果我正在做类似的事情: someString.Replace("abc","").Replace("def","").Replace(@"c:\Windows","") 我怎样才能把它替换成 Reg
我是 C# 的新手,所以请原谅我的错误。 我想在每次调用该段代码时(每次调用 2-4 次)替换字符串的某些部分。我想知道哪种方法在性能方面更好:string.Replace 或 stringBuild
当我使用 call() 或 apply() 时,我遇到了问题。 console.log(String.prototype.replace === String.replace);//false 我认为
在我使用 5-10 个替换的情况下是否有必要使用 stringbuilder。 String someData = "......"; someData = someData.replaceAll("
我有一个字符串,我需要用字典中的值替换其中的标记。它必须尽可能高效。使用 string.replace 进行循环只会消耗内存(记住,字符串是不可变的)。 StringBuilder.Replace()
我正在使用具有许多不同库依赖项的 gradle 项目并使用新的 list 合并。在我的 标签我已经这样设置了: .... 但我收到错误消息: /android/MyApp/app/src/main
我正在尝试从一个数据库中的表中提取模式并将其传输到另一个数据库。以下是执行此操作的函数的一部分。 当 Table( ... ) 时出错被称为。 功能示例: def transfer_data(self
我是一名优秀的程序员,十分优秀!