我的UI有一些从Bootstrap创建的下拉列表,我用它来包含一些表单元素.我通过我在这里找到的解决方案阻止了下拉关闭,这几乎是完美的: 避免下拉菜单关闭内部点击
剩下的问题是我使用Select2 mutliple选择并删除选项的特定实例.删除行为似乎遵循不同的事件链,因为它关闭了下拉列表.我的假设是事件传播到父元素,但我似乎无法确定哪个.
这是一个JSFiddle来说明这个问题.选择一个选项,然后将其删除以查看会发生什么.下面是包含jsfiddle时所需的代码.当然,它从我的实际代码中减少,但至少代表了这个问题.
$('body').on('click', '.dropdown .cycle-element', function(e) {
$(this).parent().toggleClass('open');
});
$('body').on('click', function(e) {
if (!$('.dropdown').is(e.target) && $('.dropdown').has(e.target).length === 0 && $('.open').has(e.target).length === 0) {
$('.dropdown').removeClass('open');
}
});
$('.dependency-select').select2();
Run Code Online (Sandbox Code Playgroud) 我有一个配置文件和用户实体。个人资料可以通过以下三种方式之一与用户相关:
这是一个基本的权限结构。我需要做的是按用户获取所有配置文件,无论授予的权限如何。我想如果我使用 Doctrine 2.5.* 我会没问题,因为 QueryBuilder 添加了“成员”比较,但我使用的是 Symfony 2.7.* ,不幸的是 Doctrine 只上升到 2.4.* (某种稳定性)如果你用低于 Symfony 3 的版本跳转到 Doctrine 2.5,这似乎是个问题。
但我不确定如何复制该功能。
<?php
namespace AppBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\EntityRepository;
class ProfileRepository extends EntityRepository
{
/**
* @param User $user
*
* @return ArrayCollection
*/
public function getAllByUser(User $user, $status = NULL)
{
$qb = $this->createQueryBuilder('p');
$e = $qb->expr();
$qb->where($e->eq('p.primary_user', ':user'));
// Some kind of comparison? a join?;
$qb->setParameter('user', $user);
$qb->setParameter('userId', $user->getId());
if ($status) {
$qb->andWhere($e->eq('p.status', ':status'));
$qb->setParameter('status', …
Run Code Online (Sandbox Code Playgroud)