小编dja*_*ngo的帖子

Bootstrap同位素和lazyload通过json获取/加载图像

ajax取出的正常同位素使用正在起作用.看工作jsfiddle.

同位素与懒惰通过ajax取不起作用.看问题jsfiddle.

问题: lazyload不会触发并继续显示灰色图像.

用于lazyload设置的javaScript:

$(document).ready(function () {
    //
    // initialize at ready ;
    //
    $container.isotope({
        itemSelector: '.box',
        columnWidth: function (containerWidth) {
            return containerWidth / 12;
        },
        onLayout: function () {
            $win.trigger("scroll");
        }
    });
    //
    // here i will be using data through api
    // For now I am defining json manually
    // var json is defined at top of this code 
    // considering json return was success
    //$.getJSON(APIURL, function (json) {
    var newElements = ""; …
Run Code Online (Sandbox Code Playgroud)

jquery jquery-isotope jquery-lazyload

5
推荐指数
1
解决办法
2610
查看次数

bind('resize')与.resize()之间的jquery区别

  1. $(window).bind('resize')和之间有什么区别$(window).resize()
  2. 我看到bind嵌套的地方resize.它有什么影响?见下面的代码.
  3. 我知道.resize()关于元素和窗口的工作.是否也bind以类似的方式工作......喜欢$('#el').bind('resize', function (event) { // stuff });

JS:

$(window).bind('resize', function (event) {
    $(window).resize(function () {
         // do something here
    });
});
Run Code Online (Sandbox Code Playgroud)

jquery

5
推荐指数
1
解决办法
5275
查看次数

jquery清空父div不删除事件的原因

  1. 有一个父div dvParent
  2. dvjQuery里面有一个儿童divdvParent

我假设当我清空时dvParent,任何通过子div上的/委托的事件都dvjQuery将被删除,但这不会发生.因此,当我单击删除按钮以清空父div dvParent并重新创建子div时dvjQuery,我仍然可以看到on.mouseenter工作.为什么?

的jsfiddle

JS:

$(document).ready(function () {
    var dvjQuery = $("<div/>").attr("id", "dvjQuery").text("some text");
    $('#btnAdd').attr('disabled', 'disabled');
    $("form").on({
        mouseenter: function () {
            $(this).addClass('highlight');
        },
        mouseleave: function () {
            $(this).removeClass('highlight');
        }
    }, '#dvjQuery');
    $('#btnRemove').click(function () { 
        $("#dvParent").empty();        
        $(this).attr('disabled', 'disabled');
        $('#btnAdd').removeAttr('disabled');
    });
    $('#btnAdd').click(function () {
        $("#dvParent").html(dvjQuery);
        $(this).attr('disabled', 'disabled');
        $('#btnRemove').removeAttr('disabled');
    });
});
Run Code Online (Sandbox Code Playgroud)

HTML:

<form>
    <div id="dvParent">
        <div id="dvjQuery">some text</div>
    </div>
    <br/><br/>
    <input type='button' id='btnRemove' Value=' Remove Div ' />
    <input type='button' id='btnAdd' …
Run Code Online (Sandbox Code Playgroud)

javascript jquery

3
推荐指数
1
解决办法
275
查看次数

在 QTableWidget 中使用 setCellWidget 对列进行排序

我正在尝试对包含进度条的列进行排序。我希望列按进度条值排序。任何帮助都感激不尽 在此处输入图片说明

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys


class Example(QMainWindow):

    def __init__(self):
        super(Example, self).__init__()

        self.initUI()

    def initUI(self):

        self.tablew = Table(self)
        self.setCentralWidget(self.tablew)

        self.setGeometry(300, 300, 300, 200)
        self.show()


class ProgressBar(QProgressBar):

    def __init__(self, value, parent=None):
        QProgressBar.__init__(self)
        self.setMinimum(1)
        self.setMaximum(5.0)
        self.setValue(value)
        self.setFormat('{0:.5f}'.format(value))
        style = ''' QProgressBar{max-height: 15px;text-align: center;}'''
        self.setStyleSheet(style)


class Table(QTableWidget):

    def __init__(self,   parent=None):
        QTableWidget.__init__(self)
        self.setColumnCount(2)
        self.setHorizontalHeaderLabels(['id', 'status'])
        header = self.horizontalHeader()
        header.setResizeMode(QHeaderView.Stretch)
        self.setSortingEnabled(True)
        self.loadData()
        #

    def loadData(self):
        #
        tableData = [[89, 4.8], [99, 3.9], [101, 2.6], [105, 4]]
        #
        self.setRowCount(len(tableData))
        #
        for …
Run Code Online (Sandbox Code Playgroud)

sorting pyqt pyqt4 qtablewidget python-2.7

3
推荐指数
1
解决办法
2222
查看次数

jQuery DataTables column.width 选项未按预期工作

我正在使用数据表

  1. 根据文档,它说使用columns.width选项来控制列宽
  2. 当我使用columns.width和渲染表格时,它忽略这个宽度并使用它自己的宽度

JSFIDDLE: https://jsfiddle.net/bababalcksheep/bvgu0cL3/28/

  1. 我正在使用带有长字符串的 2 列来测试我是否对其应用宽度
  2. 包含长字符串且不含空格
  3. 描述包含带空格的长字符串
  4. 我正在尝试将宽度 200px 应用于名称

问题:

  1. columns.width如果表格仍然强制其自己的宽度,那么这有什么意义

  2. 如何将宽度 200px 应用于名称列并查看其实际效果?

JS:

$(document).ready(function() {
  var table = $('#example').DataTable({
    'autoWidth': false,
    'scrollX': 'true',
    'scrollY': 300,
    'scrollCollapse': true,
    columns: [{
      data: 'name',
      title: 'Long Name Issues',
      width:'200px',     
      render: function(data) {
        return  '<span class="">'+ data + '</span>';
      }
    }, {
      data: 'position',
      title: 'Position'
    }, {
      data: 'description',
      title: 'Long …
Run Code Online (Sandbox Code Playgroud)

html css jquery datatables

3
推荐指数
1
解决办法
1万
查看次数

codemirror:在没有对话框的情况下搜索和突出显示多个单词

目标: 我使用codemirror作为编辑器。我想要

  1. 搜索并突出显示多个字符串
  2. 我希望能够迭代找到的每个匹配项并打印其行号。
  3. 我想以编程方式进行操作,并且不想像示例中那样使用对话框https://codemirror.net/demo/search.html

问题:

  1. 在 while 循环期间只选择最后一个匹配项,清除以前的匹配项,但我也希望它像https://codemirror.net/demo/search.html一样突出显示为黄色

JSFIDDLE: https ://jsfiddle.net/bababalcksheep/p7xg1utn/30/

代码:

$(document).ready(function() {
  //
  var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    mode: "text/html",
    lineNumbers: true,
  });
  //
  function search(val) {
    var cursor = editor.getSearchCursor(val);
    while (cursor.findNext()) {
      editor.setSelection(cursor.from(), cursor.to());
        console.log('found at line ', cursor.pos.from.line + 1);
    }
  }
  //
  $('#search').click(function(event) {
    event.preventDefault();
    search(/^alpha|^beta/);
  });

  //
});
Run Code Online (Sandbox Code Playgroud)

javascript codemirror

3
推荐指数
1
解决办法
2063
查看次数

python从子小部件调用父方法

我正在尝试printName从子小部件调用父方法,treeView 但出现错误,例如

  1. AttributeError: 'QSplitter' 对象没有属性 'printName'
  2. QObject::startTimer:QTimer 只能用于以 QThread 启动的线程

为什么父母指的是 QSplitter ?

的父级TreeView应该是compositeWidget因为TreeView创建于 compositeWidget

代码:

from PyQt4.QtCore import *
from PyQt4.QtGui import *
import sys


class MainExample(QMainWindow):

    def __init__(self, parent=None):
        super(MainExample, self).__init__(parent)
        self.initUI()

    def initUI(self):
        self.mainWidget = compositeWidget(self)
        self.setCentralWidget(self.mainWidget)
        self.mainWidget.treeView.setPath('D:\DATA')
        self.setGeometry(300, 300, 300, 200)


class TreeView(QTreeView):

    def __init__(self, parent):
        super(TreeView, self).__init__(parent)
        self.clicked.connect(self.on_treeView_clicked)

    @pyqtSlot(QModelIndex)
    def on_treeView_clicked(self, index):
        indexItem = self.FileSystemModel.index(index.row(), 0, index.parent())
        filePath = self.FileSystemModel.filePath(indexItem)
        self.parent().printName(filePath)
        #

    def setPath(self, path):
        self.FileSystemModel …
Run Code Online (Sandbox Code Playgroud)

python pyqt pyqt4

2
推荐指数
1
解决办法
4163
查看次数

电子通过中键防止多个实例

我正在制作单实例电子应用程序。我正在使用app.makeSingleInstance,请参阅下面的示例。

中键的 SingleInstance 问题:

  1. 如果我第二次单击 app.exe,单实例工作
  2. 如果我在我的应用程序中点击一个链接,它就不起作用

我需要的:

  1. 使电子应用程序单实例并确保即使单击中键它仍然是单实例。
  2. 我不想像在某些地方那样在我的应用程序中强制禁用中间单击,我在非链接项目上有一个用例

如何重现:

  1. 使用回购:https : //github.com/electron/electron-quick-start
  2. 用我的index.html和替换现有的main.js,见下文
  3. npm install 进而 npm start

索引.html:

<!DOCTYPE html>
<html>
  <head><meta charset="UTF-8"><title>Hello World!</title></head>
  <body>
    <h1>app.makeSingleInstance()</h1>
    <a href="$">Middle Click on it</a>
  </body>
</html>
Run Code Online (Sandbox Code Playgroud)

主文件

const electron = require('electron')
const app = electron.app
const BrowserWindow = electron.BrowserWindow
const path = require('path')
const url = require('url')
let mainWindow
const isSecondInstance = app.makeSingleInstance((commandLine, workingDirectory) => {
  if (myWindow) {
    if (myWindow.isMinimized()) …
Run Code Online (Sandbox Code Playgroud)

node.js electron

2
推荐指数
1
解决办法
1710
查看次数

jquery multiselect:非选定选项的计数不起作用

我试图在多选中未选中.但似乎有一些问题.请参阅小提琴了解更多..

问题:

  1. 试着点击Select allDeselect all按钮几次,并Select all停止工作.
  2. 即使Select all停止在视觉上工作,它仍然在dom中选择/取消选择.你可以使用萤火虫来检查它.
  3. 如果是在dom中选择/取消选择,为什么它为取消选择的元素提供了错误的计数?

注意:

请在下面的小提琴下按照这个确切的顺序查看我的问题.点击Select all,然后Deselect all ,然后再次Select all.此时DOM/Firebug显示选项被选中.但是当我按下计数时,我得到结果4的实例0.

目标:我不在乎它是否在视觉上进行选择,我的主要目的是获得正确计数未选择的选项,因为firebug显示"选项"正在被选中和取消选择.

JSFIDDLE: http ://jsfiddle.net/bababalcksheep/fgfdb/

HTML:

<button id="countdeselected">Count deselected</button>
<button id="selectall">select All</button>
<button id="deselectall">Deselect All</button>
<select name="languages[]" multiple="multiple" class="multiselect" id="languages" style=" ">
    <option value="ALB">Albania</option>
    <option value="DZA">Algeria</option>
    <option value="alfa">Custom1</option>
    <option value="beta">Custom2</option>
</select>
<ul id="status"></ul>
Run Code Online (Sandbox Code Playgroud)

JS:

$("#countdeselected").click(function (event) {
    var dd = $("#languages option:not(:selected)").length
    $('#status').append($('<li>').text(dd));

});

$("#selectall").click(function (event) {
    $("#languages option").attr('selected', 'selected');
}); …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

1
推荐指数
1
解决办法
1684
查看次数

jQuery UI Sortable 连接列表 css 问题

我正在使用可通过连接列表排序的 jquery ui。我有一个最重要的要求有两个问题。

  1. 拖动时项目落后于另一个列表 li.ui-splitselect-item
  2. 向右拖动项目(当鼠标太右时)创建水平滚动

重要提示: 列表ul.ui-splitselect-list应该有overflow-y:auto;所以列表的标题保持固定并且只有列表项被滚动 在此处输入图片说明

注意: 我之前在STACKOVERFLOW上问过这个问题,但没有注意到解决方案中缺少我的重要要求,所以我再次明确地提出了问题。

JSFIDDLE: http : //jsfiddle.net/bababalcksheep/z67Td/

HTML样机:

<div class="ui-splitselect ui-helper-clearfix ui-widget ui-widget-content" style="height:200px;" >
    <div class="ui-widget-content ui-splitselect-selected">
        <div class="ui-widget-header ui-helper-clearfix">
             List1
        </div>
        <ul id="sortable1"  class="ui-splitselect-list" style="height: 332px;">
            <li class="ui-splitselect-item ui-state-default">
                <a class='ui-splitselect-handle-drag'><span class='ui-icon ui-icon-carat-2-n-s'></span></a>
                <span class="ui-splitselect-handle-select">TEST-List1</span>
                <a class="ui-splitselect-handle-move" href="#"><span class="ui-icon ui-icon-plus"></span></a>
            </li>  
        </ul>
    </div>
    <div class="ui-widget-content ui-splitselect-available"  >
        <div class="ui-widget-header ui-helper-clearfix">
              List2
        </div>
        <ul id="sortable2"  class="ui-splitselect-list" style="height: 332px;">
        </ul>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

.ui-splitselect{font-size:.8em;width:100%!important;text-align:center;margin:0 auto;padding:0}
.ui-splitselect ul{-moz-user-select:none} …
Run Code Online (Sandbox Code Playgroud)

javascript css jquery jquery-ui jquery-ui-sortable

1
推荐指数
1
解决办法
3361
查看次数

jquery选择父元素

我试图在按钮处于类页脚中时找到类前面的href属性.似乎无法使其发挥作用.

的jsfiddle:

HTML

<div class="panel">
    <div class="front"> 
        <a rel="lightbox" href="asas/as/abc.html">
            <img width="200" height="125" src="http://www.wired.com/wiredenterprise/wp-content/uploads//2012/10/stormtroopers-sm.png"  >
        </a>
        <div class="footer">
            <button class="btn btn-mini" rel="btn_scr"><i class="icon-fullscreen"></i> </button>
        </div>
    </div>
    <div class="back" style="width: 200px; height: 157px;">something here</div>
</div>
Run Code Online (Sandbox Code Playgroud)

JAVA

$('body').on('click', '[rel=btn_scr]', function (event) {
    event.preventDefault();
    var data = $(this).parents(".front > a").attr("href");
    alert(data);
    //console.log(data);

});   
Run Code Online (Sandbox Code Playgroud)

jquery

0
推荐指数
1
解决办法
42
查看次数

jQuery off().remove()或.remove().off()性能

我在stackoverflow上阅读了不同的答案,我如何销毁wigdet/jQueryObject并取消绑定它上面的所有事件.

这就是我想出来的.

  1. $('selector').remove().off().find("*").off();
  2. $('selector').off().remove().find("*").off();

问题: 我的问题是关于上述2的表现.通过改变订单会有性能差异.使用off()之后remove()或之前有区别remove()吗?或者它是一样的,顺序并不重要,性能明智吗?

更新:

还有什么关于空

  1. $('selector').empty().off().find("*").off();
  2. $('selector').off().empty().find("*").off();

javascript jquery

0
推荐指数
1
解决办法
209
查看次数