当前页面刷新和动态添加控件的jquery事件绑定on

当前页面刷新(console):

  location.reload()javascript

给动态添加的控件添加js事件(委托):

<ul>
        <li>菜单一</li>
        <li>菜单二</li>

    </ul>

       //直接添加
        $('li').click(function () { }) //经过委托,动态添加的控件,响应js事件
        $('ul').on('click', 'li', function () { }) 

 添加一个a标签,什么都不作:前端

  pager_list.append('<a href="javascript:void(0);''>上一个</a>)java

 

XSS, 安全的渲染: 

 前端: 后端

<div class="pagination">
{{ str_pager|safe }}
</div>
后端:
  mark_safe()

给标签添加自定义属性,获取属性值:

filter查询使用字典替换键值对:   

  models.tb.objects.filter(id=123)

  dic = {'id': 123, 'age__gt': 3}
  models.tb.objects.filter(**dic)安全

 

修改主键关联(默认是id):

class Province(models.Model):
  name = models.CharField(max_length=32,)
  # nid = models.Intergar(unique=True) # 惟一app

 

class City(models.Model):
  name = models.CharField(max_length=32)
  pro = models.ForeignKey("Province", to_filed='id')ide

 

正向查找: 具备外键字段post

function bindtdEditEvent() { $('tbody').on('click', '.td-edit', function () { $('.modal, .shade').removeClass('hide') var tds = $(this).parent().prevAll() {#$('.modal input[name="caption"]').val(tds[0].innerText)#} {#$('.modal input[name="id"]').val(tds[1].innerText)#} tds.each(function () { {#$(this).parent().prevAll().each(function () {#} var text = $(this).text() var name = $(this).attr('param') {#console.log(text)#} console.log(name) {#$('.modal input[name="'+ name +'"]').val(text)#} $('.modal input[name="'+ name +'"]').val(text) }) }) }
View Code

 

post请求获取多个参数:

 def index(request): this

  request.POST.get('k')spa

  #checkbox, select(multi)

  request.POST.getlist('k')

not inmodels.Teacher.objects.exclude(id__in=[1,2,3])