zoukankan      html  css  js  c++  java
  • 当前页面刷新和动态添加控件的jquery事件绑定on

    当前页面刷新(console):

      location.reload()

    给动态添加的控件添加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>)

    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) # 唯一

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

    正向查找: 具有外键字段

            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): 

      request.POST.get('k')

      #checkbox, select(multi)

      request.POST.getlist('k')

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

  • 相关阅读:
    Android 5.0以上手机出现找不到so文件
    面向对象:析构方法-__del__
    面向对象:类中的反射及其应用
    面向对象:内置方法call、len、new、str
    面向对象-内置函数isinstance()和issubclass()
    面向对象:类方法(classmethod),静态方法(staticmethod)
    面向对象:属性-装饰器函数@property
    面向对象的三大特性: 封装
    面向对象:接口类、抽象类
    面向对象的三大特性: 多态
  • 原文地址:https://www.cnblogs.com/jiefangzhe/p/10737383.html
Copyright © 2011-2022 走看看