我试图在第一次单击后禁用 li 单击事件。本质上是为了阻止数组数据翻倍。每次点击都正常。我目前的方法似乎不起作用。我还需要禁用其他 li 一旦第一个有 :)
谢谢
JS代码是:
$('#eventType ul li').click(function(e) {
e.preventDefault();
var value = $(this).attr('value');
answers.push(value);
// Below isn't working
$(this).click(function() {
return false;
});
console.log(answers);
});
Run Code Online (Sandbox Code Playgroud) 尝试初始化集合视图类并收到以下错误:
必须调用超类'UICollectionView'的指定初始值设定项
数据正在从另一个ViewController传递,我希望在用户搜索时从ViewController中抽出框架.
class searchLocationsCollectionViewManager: UICollectionView, UICollectionViewDataSource, UICollectionViewDelegate {
weak var collectionView: UICollectionView! {
didSet {
collectionView.dataSource = self
collectionView.delegate = self
}
}
// Data handler
var data: [[String:Any]]? {
didSet {
print(data!)
//collectionView.reloadData()
}
}
init(collectionView: UICollectionView, frame: CGRect) {
self.collectionView = collectionView
super.init()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
}
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 3
}
// This …
Run Code Online (Sandbox Code Playgroud)