Lydia's blog

Every day to be a little better


  • Home

  • Archives

  • Search

sql 基础(pgsql & mysql)

Posted on 2019-01-15 14:45

pgsql

  1. 进入本地数据库

    1
    psql resumehack_development
  2. 进入服务器数据库
    console 直接连数据库 bin/rails dbconsole production

  3. 修改数据库密码
    \password

  4. 查看数据库大小

    Read more »

js-在数组中固定位置插值

Posted on 2019-01-07 12:33
1
2
3
4
5
6
7
// 原来的数组
var array = ["one", "two", "four"];
// splice(position, numberOfItemsToRemove, item)
// 拼接函数(索引位置, 要删除元素的数量, 元素)
array.splice(2, 0, "three");

array; // 现在数组是这个样子 ["one", "two", "three", "four"]

rails - js rendern

Posted on 2018-12-26 14:45
1
$('#recruit_info_customize_company_intro').val('<%=j @company.intro%>')

ruby-match

Posted on 2018-12-25 18:35
1
2
str = '产品xxx产品经理'
str.match(/(产品)/).size

js-textarea文字计数

Posted on 2018-12-21 18:36
1
2
3
4
5
6
<div class='input-field'>
<%= f.text_area :jd, value: text, maxlength: '100'%>
<span class='text-num'>
<span class='real-text-num'>0</span>/100
</span>
</div>
1
2
3
$(document).on('input propertychange paste keyup','#recruit_info_jd', function(event) {   
$(this).closest('.input-field').find('span.text-num .real-text-num').html($(this).val().length)
})

js- textarea placeholder 换行显示

Posted on 2018-12-21 18:30
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var placeholder = "This is a line \nthis should be a new line"
$(document).ready(function(){
if($('#recruit_info_jd').val() == ''){
$('#recruit_info_jd').val(placeholder)
$('#recruit_info_jd').css('color', "#999")
}
}
$('#recruit_info_jd').focus(function(){
if($(this).val() === placeholder){
$(this).val('');
$(this).css('color', '#404040');
}
});
$('#recruit_info_jd').blur(function(){
if($(this).val() ===''){
$(this).val(placeholder);
$('#recruit_info_jd').css('color', "#999")
}
});

html-txt area换行

Posted on 2018-12-14 15:52

文字拼接成字符串,要换行:拼接”\n”
ps:一定得是双引号

jquery-highlight

Posted on 2018-12-08 18:06

参考

jquery- autocomplete

Posted on 2018-12-08 17:44
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
$( "#jd-temp-name" ).autocomplete({
source: function (request, response) {
$.ajax({
dataType: "json",
type : 'Get',
url: '<%= search_jd_temps_path%>',
data:{
name: request.term,
},
success: function(data) {
console.log(data.professions)

var items = [];

$.each( data.professions, function(key, val){
items.push("<div class='result-item'>" + val.level3 + "<div class='subtitle'>" + val.level1 + "-" + val.level2 + "</div></div>")
});

console.log(items)
response(items);
},
error: function(data) {
console.log('fail')
}
});
},
}).data('ui-autocomplete')._renderItem = function(ul, item){
var expression = new RegExp(this.term,'gi')
var result = item.label.replace(expression, "<span style='color: #ff4f4c!important;'>" + this.term + "</span>")
return $("<li></li>").append(result).appendTo(ul)
}

js-监听input 输入中文

Posted on 2018-12-08 15:55
1
2
3
4
5
6
7
8
9
10
11
12
13
14
var cpLock = false;
$('#jd-temp-name').on('compositionstart', function () {
cpLock = true;
});
$('#jd-temp-name').on('compositionend', function () {
cpLock = false;
});
$('#jd-temp-name').on('input', function() {
if (!cpLock) {
setTimeout(function () {
$('#jd-temp-search-form').submit()
}, 1)
}
})
1…678…28

Lydia

This is lydia's blog

277 posts
1 categories
46 tags
© 2020 Lydia
Powered by Hexo
|
Theme — NexT.Muse v5.1.4