小编Rey*_*ier的帖子

通过ajax加载的Html不适用于jQuery事件

我把这个代码放在一个名为checkout.tpl的文件中,也有一个Javascript代码,我将在下面发表评论:

$.ajax({
    url: 'index.php?route=checkout/payment_address',
    dataType: 'html',
    success: function(html) {
        $("#checkout").hide();
        $('#payment-address .checkout-content').html(html);
    },
    error: function(xhr, ajaxOptions, thrownError) {
        alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    }
});
Run Code Online (Sandbox Code Playgroud)

正如您在这里看到的,我使用AJAX加载了一些HTML内容.这是我正在加载的HTML内容.注意输入id = button-payment-address.所以在checkout.tpl中我有这个jQuery代码:

$('#button-payment-address').on('click',function() {
    alert("Click");
    // here goes some code   
});
Run Code Online (Sandbox Code Playgroud)

当我点击带有id = button-payment-address的输入时,会出现带有"Click"的警告吗?好不显示,代码永远不会执行,没有错误触发,所以我不知道什么是错的.我用其他代码测试并得到相同的结果:

$('#button-payment-address').click(function() {
    alert("Click");
    // here goes some code   
});

// This seems to be not working with latest jQuery and generates a error
$('#button-payment-address').live('click', function() {
    alert("Click");
    // here goes …
Run Code Online (Sandbox Code Playgroud)

ajax jquery html5

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

Microsoft.Office.Interop.Excel 或 EPPlus 用于读取巨大的(或不是)Excel 文件

我编写了一个代码来从 Excel 文件中读取一列。我在此使用 Microsoft.Office.Interop.Excel,首先读取整个范围,然后写入 System.Array,然后对 System.Array 值进行一些操作,最后将其转换为 List,因为我填充了一个 ListBox 元素。这是代码(仅相关部分):

private List<string> bd = new List<string>();
private static System.Array objRowAValues;

private List<string> bl = new List<string>();
private static System.Array objRowBValues;

private List<string> cm = new List<string>();
private static System.Array objRowCValues;

private List<string> pl = new List<string>();
private List<string> bdCleanList;
private static Microsoft.Office.Interop.Excel.Application appExcel;

Excel.Application xlApp;
Excel.Workbook xlWorkBook;
Excel.Worksheet xlWorkSheet;
Excel.Range rngARowLast, rngBRowLast, rngCRowLast;

long lastACell, lastBCell, lastCCell, fullRow;

private void btnCargarExcel_Click(object sender, EventArgs e)
    {
        if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
        { …
Run Code Online (Sandbox Code Playgroud)

.net c# excel-interop epplus

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

如果类包含带有class ="dropdown-menu"的UL,则将类添加到父LI

我需要向dropdown-submenu父类添加一个类,LI如果它有一个UL带有类的内部元素dropdown-menu.这是HTML代码的示例:

<ul class="dropdown-menu" id="menu1">
        <li>
            <a href="#">More options</a>
            <ul class="dropdown-menu">
                <li><a href="#">Second level link</a></li>
                <li><a href="#">Second level link</a></li>
                <li><a href="#">Second level link</a></li>
                <li><a href="#">Second level link</a></li>
                <li><a href="#">Second level link</a></li>
            </ul>
        </li>
</ul>
Run Code Online (Sandbox Code Playgroud)

我还没有尝试任何东西,因为不知道如何检查<ul class="dropdown-menu">每个LI元素是否存在.有帮助吗?

html jquery

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

"1064你的SQL中有错误",同时尝试使用Symfony2和Doctrine2执行INSERT

我正在使用Symfony2和Doctrine2 ORM执行查询,但是我收到此错误:

执行'INSERT INTO stock_detail_has_product_detail(content,created,modified,deletedAt,stock_detail,upc,product,condition,company,product_detail)VALUES(?,?,?,?,?,?,?,?,?, ?)'with params ["Negro","2013-09-29 02:54:46","2013-09-29 02:54:46",null,1,"AR024MHLXF83XZO3LQ78",1,1,51, 1]:

SQLSTATE [42000]:语法错误或访问冲突:1064 SQL语法中有错误; 检查与MySQL服务器版本对应的手册,以便在'condition,company,product_detail'附近使用正确的语法VALUES('Negro','2013-09-29 02:54:46','201'在第1行

而且我找不到导致这种情况的原因,我检查表格,列长度等等,似乎没问题,可以给我一些提示或指出我正确的方向吗?

PS:查询是由Doctrine内部生成的,因为我只是将对象持久保存到DB

mysql symfony doctrine-orm symfony-2.3

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

检查Doctrine结果是NULL还是空或没有任何记录

哪种方法可以检查Doctrine查询结果是空的还是没有值以便向用户显示消息?我有这个代码:

public function executeIndex(sfWebRequest $request) {
        $this->sdriving_emisors = Doctrine_Core::getTable('SdrivingEmisor')->createQuery('a')->execute();
}
Run Code Online (Sandbox Code Playgroud)

在我看来,我正在检查如下:

<?php if (!empty($sdriving_emisors)): ?>
  // show records
<?php else: ?>
  // show message
<?php endif; ?>
Run Code Online (Sandbox Code Playgroud)

但是因为$sdriving_emisors总是有内容不起作用,所以有什么帮助吗?PS:我正在使用Symfony 1.4.20

doctrine symfony-1.4 doctrine-1.2

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

我可以使用动作帮手吗?

我试图以这种方式使用动作中的帮助器:

sfContext::getInstance()->getConfiguration()->loadHelpers(array('I18N', 'Asset', 'Url'));
echo image_tag('bullet_red.png');
echo link_to('Ver detalles', 'ver-detalles/' . $record->getIdregistros(), 'class="btn btn-success btn-mini"');
Run Code Online (Sandbox Code Playgroud)

但是我得到这个错误:

致命错误:在第333行的/var/www/html/monitor/lib/vendor/symfony/lib/helper/AssetHelper.php中调用未定义的函数_parse_attributes()

为什么?

symfony1 symfony-1.4

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

删除DIV中除按钮以外的所有HTML

我需要从DIV中删除所有内容(动态创建),但不删除默认情况下存在的按钮.这是HTML:

<div id="{{ entity.getLabel|lower ~ "_choice_" ~ entity.getId }}" style="display: none">
    <button type="button" class="add-size">Adicionar {{ entity.getLabel|lower }}</button>
</div>
Run Code Online (Sandbox Code Playgroud)

而我正在做如下:

$("#" + theName + '_choice_' + theID).empty();
$("#" + theName + '_choice_' + theID).hide();
Run Code Online (Sandbox Code Playgroud)

当然,变量采取正确的值,我只是强硬.empty()删除所有,我需要离开按钮,我是怎么做到的?

PS:在这两种情况下,HTML和jQuery代码都忘记了vars和Twig标签,因为它完成了我需要替换$.empty()一些工作代码的工作

javascript jquery

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

验证具有相同名称和类的字段得到"TypeError:e.validator.methods [o]未定义"

我有这个HTML代码:

<section id="variations_holder">
    <input type="text" name="field1" class="pprice" />
    <br/>
    <input type="text" name="field2" class="pprice" />
    <br/>
    <input type="submit" />
</section>
Run Code Online (Sandbox Code Playgroud)

这是我用来处理验证的代码:

$('#variations_holder input.pprice').each(function() {
    $(this).rules('add', {
        required: true,
        number: true,
        messages: {
            required: "Debes introducir un precio de la variación",
            number: "El precio de la variación debe ser un valor numérico o decimal"
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

它可以工作,但是当HTML看起来像这样(通知输入具有相同的名称):

<section id="variations_holder">
    <input type="text" name="field1" class="pprice" />
    <br/>
    <input type="text" name="field1" class="pprice" />
    <br/>
    <input type="submit" />
</section>
Run Code Online (Sandbox Code Playgroud)

相同的代码停止工作并导致此错误:

TypeError:e.validator.methods [o]未定义

我该如何解决这个问题?

这源于这个问题

jquery jquery-validate

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

为什么我只得到".xlsx"而不是完整的连接字符串

在保存到我的电脑之前,我写了这段代码来设置文件名:

string name_file = System.IO.Path.GetFileName(openFileDialog1.FileName).Split('.')[0]
                   + blYear.SelectedValue == null ? "2010" : blYear.SelectedValue 
                   + ".xlsx"; 
Run Code Online (Sandbox Code Playgroud)

我跟踪代码并查看结果:

System.IO.Path.GetFileName(openFileDialog1.FileName).Split('.')[0]  "PSIQ DIGITEL"  string
blYear.SelectedValue                                                null            object
name_file                                                           ".xlsx"         string
Run Code Online (Sandbox Code Playgroud)

我做错了什么?为什么会name_file丢失原始值?另外,对于同样的问题,我如何删除最终file_name之间的空格,比如示例中的"PSIQ DIGITEL"应为"PSIQ-DIGITEL".

编辑

如果我删除这部分,+ blYear.SelectedValue == null ? "2010" : blYear.SelectedValue那么文件名取值很好,有什么不对?

.net c#

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

单击按钮时获取下一个/上一个 ID

我有这个 HTML:

<form action="" id="product_create" method="post">
    <ul>
        <li id="tab1" data-display="categories-picker"><a href="#">Seleccionar categoría</a></li>
        <li id="tab2" data-display="product-create-step-2"><a href="#">Datos</a></li>
        <li id="tab3" data-display="product-create-step-3" style="display: none"><a href="#">Variaciones</a></li>
        <li id="tab4" data-display="product-create-step-4"><a href="#">Detalles del Producto</a></li>
        <li id="tab5" data-display="product-create-step-5"><a href="#">Condiciones de Venta</a></li>
    </ul>

    <fieldset id="categories-picker">
        ....
    </fieldset>

    <fieldset id="product-create-step-2" style="display: none">
        ....
    </fieldset>

    <fieldset id="product-create-step-3" style="display: none">
        ....
    </fieldset>

    <fieldset id="product-create-step-4" style="display: none">
        ....
    </fieldset>

    <fieldset id="product-create-step-5" style="display: none">
        ....
    </fieldset>

    <button type="button" name="finish-wizard" id="finish-wizard" style="display:none">Finish</button>
</form>

<button type="button" name="previous" id="previous-step" disabled="disabled">&#171; Previous</button>
<button type="button" name="next" id="next-step">Next &#187;</button> …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery

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

这个jQuery代码不应该返回#product-create-2中的所有输入吗?

我有这个HTML:

<fieldset style="display: block;" title="Producto" class="fstep" id="product-create-step-2">
    <section>
        <div class="p_name">
            <input type="text" maxlength="50" required="required" name="product[name]" id="product_name">
        </div>
        <div class="p_description">
            <textarea required="required" name="product[description]" id="product_description"></textarea>
        </div>
        <div class="p_age">
            <input type="text" value="0" name="product[age_limit]" id="product_age_limit">
        </div>
    </section>
</fieldset>
Run Code Online (Sandbox Code Playgroud)

我正在尝试required="required"使用空值显示每个元素的警报,所以我做了这个:

$('#product-create-step-2 > input[required="required"]').each(function() {
    if (!$.trim(this.value).length) {
        alert($(this).prev('label').text() + ' can't be empty!!!');
        valid = false;
    }
});
Run Code Online (Sandbox Code Playgroud)

如果我离开#product_name#product_description清空,它从不显示警报,我找不到我想念的任何建议?

javascript jquery

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

删除第二个tr元素上的第一个链接

我有这个HTML:

<table>
    <tr>
        <td colspan="2"> Some text </td>
    </tr>
    <tr>
        <td> Some text </td>
        <td>
            <div class="btn-group">
                <a class="btn btn-link" href="/pingenieros/web/app_dev.php/admin/pi/proyecto/proyectos/create"><i class="icon-plus"></i>New</a>
                <a class="btn btn-link" href="/pingenieros/web/app_dev.php/admin/pi/proyecto/proyectos/list"><i class="icon-list"></i> List</a>
            </div>
        </td>
    </tr>
    <tr>
     ... many others tr ...
    </tr>
</table>
Run Code Online (Sandbox Code Playgroud)

我需要使用jQuery删除a第二个中的第一个元素,tr意思是带New文本的那个,有什么建议吗?

注意:我的坏了一个错字

html javascript jquery dom

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

如果条件为真,则在HTML中包装文本

我需要将文本包装在此HTML标记中的<a>between <div> .... </div>标记内:

<li class="first current">
  <a href="http://dts.devserver/">Home</a>
</li>
<li class="last has_children sub-menu">
  <a href="http://dts.devserver/blog">Blog</a>
</li>
Run Code Online (Sandbox Code Playgroud)

但只有当LI有has_children类时,结果应该是:

<li class="first current">
  <a href="http://dts.devserver/">Home</a>
</li>
<li class="last has_children sub-menu">
  <a href="http://dts.devserver/blog"><div>Blog</div></a>
</li>
Run Code Online (Sandbox Code Playgroud)

我应该使用哪个jQuery代码或方法或属性?在这有任何帮助吗?

jquery html5

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