我在Twitter Bootstrap Modal之上构建了一些模态,每个模式都有至少一个提交按钮,这是我在大多数情况下需要触发的默认操作,因为第二个按钮用于返回(关闭模态),如何,打开一个模态,当我按Enter键时,我可以触发提交的任何动作吗?例如,现在,因为它们是按钮我有类似的东西:
$("#btn").on("click", function(e){
e.preventDefault(); // wait... not send form yet, will be a Ajax call
});
Run Code Online (Sandbox Code Playgroud)
有帮助吗?示例代码?
作为参考,这是模态内容(我使用Twig作为Symfony2项目的一部分,所以不要担心{{ }}):
<div class="modal fade " id="addNorma" tabindex="-1" role="dialog" aria-labelledby="addNorma" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">{{ 'boton.cerrar'|trans({}, 'AppBundle') }}</span></button>
<h4 class="modal-title" id="myModalLabel">{{ 'modal.normas.titulo'|trans({}, 'AppBundle') }}</h4>
</div>
<div class="modal-body">
<form id="buscadorNorma" method="POST">
<div class="spacer10"></div>
<div class="row">
<div class="col-md-5 col-lg-5 col-sm-5 col-xs-5">
<label for="codigo_norma">{{ 'modal.normas.codigo'|trans({}, 'AppBundle') }}</label>
<input type="text" class="form-control" id="codigo_norma" …Run Code Online (Sandbox Code Playgroud) 我有这个jQuery代码:
html += '<tr>';
html += '<td>AAA</td>';
html += '<td>BBB</td>';
html += '<td>CCC</td>';
html += '<td>DDD</td>';
html += '<td>EEE</td>';
html += '<td>FFF</td>';
html += '</tr>';
$(html).appendTo("#fabricanteBody");
$(html).appendTo("#selFabricanteBody");
Run Code Online (Sandbox Code Playgroud)
如何在删除之前删除var 上的last td(html += '<td>FFF</td>')元素?html#selFabricanteBody
我在Twig模板上有这个代码:
{% if form_action is empty or form_action is null or form_action is not defined %}
{% set form_action = '' %}
{% endif %}
Run Code Online (Sandbox Code Playgroud)
但是当我加载页面时,我收到此错误消息:
第1行的AppBundle :: pdone.html.twig中不存在变量"form_action"
如何检查变量是否设置?条件不够吗?有什么建议?
我有这个听众:
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\HttpKernel\Event\FilterControllerEvent;
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
use Symfony\Component\HttpFoundation\Request;
class ControllerListener
{
public function onKernelController( FilterControllerEvent $event, Request $request )
{
if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
$controllers = $event->getController();
if (is_array( $controllers )) {
$controller = $controllers[0];
if (is_object( $controller )) {
if (method_exists( $controller, 'parControl' )) {
$controller->parControl(
$controller->getRequest(),
$controller->getRequest()->get( 'action' ),
$controller->getRequest()->get( 'context' ),
$controller->getRequest()->get( 'page' ),
$controller->getRequest()->get( 'case' ),
$controller->getRequest()->get( 'subset' )
);
}
if (method_exists( $controller, 'adminProjectControl' )) {
// to this method I need to …Run Code Online (Sandbox Code Playgroud) 尽管很多人都想关闭此职位,但我还是应该问我在做什么错,因为我发疯了,无法找到解决方案。
我已经在Fedora 24中安装了Docker,一切似乎都很好,但是没有它我就无法运行docker命令sudo,这很烦人(至少对我而言)。
我以普通用户(非root用户)身份登录,并且只要运行命令,我就会看到以下消息:
$ docker ps
Cannot connect to the Docker daemon. Is the docker daemon running on this host?
Run Code Online (Sandbox Code Playgroud)
但是,如果只运行,docker我会看到可能的命令列表:-\
我遵循了本指南,并且阅读了很多(这里是一小列):
但是肯定我缺少了什么,有什么可以照亮我的吗?我在这里想念的是什么?我知道问题会变成用户没有权限,/var/run/docker.sock但是解决方法是什么?
我需要动态更改元素类型,下面是我正在做的事情:
$(function() {
$('.click_me').click(function(ev) {
var condition_value_1 = $('#condition_value_1');
var select_html = '<select name="condition_value_1" id="condition_value_1"></select>';
condition_value_1.after().html(select_html);
condition_value_1.remove();
});
});Run Code Online (Sandbox Code Playgroud)
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<input type="text" id="condition_value_1">
<span class="click_me">Click Me</span>Run Code Online (Sandbox Code Playgroud)
在上面的代码片段中看到的更改类型后,我应该删除前一个元素,但因为它们共享(并且这是必需的)相同的ID,所以新的SELECT将被删除.有什么方法可以避免这种情况吗?
我有一个位于 q jQuery UI 模式中的表单,并且 Parsley.js 无法正常工作,因为验证消息未显示在 UI 上。
这是我一直在玩的代码:
$(function() {
$('#order_push').click(function() {
$('#add_contact').dialog('open');
});
$('#add_contact').dialog({
title: "Add Contact",
autoOpen: false,
modal: true,
width: 600,
height: 300,
buttons: {
'Create': function() {
var $form = $('#contact_frm').parsley();
if ($form.isValid()) {
alert('valid');
}
}
}
});
});
Run Code Online (Sandbox Code Playgroud)
这是HTML 和 JS 协同工作的完整示例。如果您通过将字段留空来稍微玩一下这个小提琴,您将看到消息是如何不显示的。至少我希望我的字段如果无效则标记为红色,如果有效则标记为绿色。像这样的东西
我在这里错过了什么吗?
我有这段代码:
$entity = $em->getRepository('AppBundle:Representative')->find($soqlObj1['records'][0]['Id']);
if ($entity === null) {
$entity = new Representative();
$em->persist($entity);
}
// we set the values from veeva
$entity->setVeevaRepId($soqlObj1['records'][0]['Id']);
$entity->setEmail($soqlObj1['records'][0]['Email']);
...
$em->flush();
Run Code Online (Sandbox Code Playgroud)
这是实体的一部分Representative:
class Representative
{
/**
* @ORM\Id()
* @ORM\Column(type="string", length=45, nullable=false, unique=true)
* @ORM\GeneratedValue()
* @Expose()
*/
protected $veeva_rep_id;
/**
* @var string
* @ORM\Column(type="string", length=45)
* @Expose()
*/
protected $display_name;
/**
* @var string
* @ORM\Column(type="string", length=255)
* @Expose()
*/
protected $avatar_url = 'https://pdone.s3.amazonaws.com/avatar/default_avatar.png';
/**
* @var string
* @ORM\Column(type="string", length=45) …Run Code Online (Sandbox Code Playgroud) 我有一个路由和方法以这种方式操纵URL:
http://domain.com/combivent?email=WGA1cUtKZi4
Run Code Online (Sandbox Code Playgroud)
现在该URL已更改为此URL:
http://domain.com/?email=WGA1cUtKZi4
Run Code Online (Sandbox Code Playgroud)
但旧的电子邮件仍旧保留旧电子邮件.我需要将每个URL从旧方式重定向到新方式.例如,如果我调用它,http://domain.com/combivent?email=WGA1cUtKZi4那么我应该重定向到http://domain.com/?email=WGA1cUtKZi4如何在Symfony2中实现这一点?我可以在路由中使用任何类型的通配符,还是我需要保留这两种方法并在内部处理它?这可以在.htaccess水平上完成吗?有什么建议?
这是.htaccess看起来像:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
RewriteRule ^(.*) - [E=BASE:%1]
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteCond %{ENV:REDIRECT_STATUS} ^$
RewriteRule ^app\.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule .? - [L]
# Remove combivent word from the URL when call a brand page
RewriteRule ^combivent?email=([^/]+)$ /?email=$1 [L,QSA,R=301]
RewriteRule .? %{ENV:BASE}/app.php [L]
</IfModule>
Run Code Online (Sandbox Code Playgroud)
此外,这domain.com是共享三个域的VirtualHost的别名.将VH定义视为:
ServerName maindomain.com
ServerAlias domain.com
ServerAlias domain1.com
Run Code Online (Sandbox Code Playgroud)
更新
以下是完整.htaccess定义: …
javascript ×4
jquery ×4
php ×4
symfony ×4
html ×2
.htaccess ×1
docker ×1
doctrine-orm ×1
fedora ×1
parsley.js ×1
redirect ×1
root ×1
symfony-2.6 ×1
symfony-2.7 ×1
twig ×1
url-routing ×1