小编fre*_*rks的帖子

jQuery可点击表格行,带有特定类名的td除外

我有这样的桌子

<tbody>
   <tr class="row-links" data-link="http://mylink.com">
     <td>some cell</td>
     <td>some cell</td>
     <td>some cell</td>
     <td class="special-td"><a href="http://followthis.com">special cell</a></td>
     <td>some cell</td>
     <td class="special-td">special cell</td>
     <td>some cell</td>
   </tr>
</tbody>
Run Code Online (Sandbox Code Playgroud)

我想使整行都可单击,希望有一些“特殊单元格”,我已经给它们指定了一个识别类名“ specal-td”

通常,整行的链接存储在“数据链接”属性中

到目前为止,我想出的代码不起作用如下:

$('.row-links td:not(.special-td)').on('click', function(e){


    //get the link from data attribute
    var the_link = $(this).attr("data-link");

    //do we have a valid link      
    if (the_link == '' || typeof the_link === 'undefined') {
        //do nothing for now
    }
    else {
        //open the page
        window.location = the_link;
    }
});
Run Code Online (Sandbox Code Playgroud)

任何帮助都是最欢迎的

更新:

多亏了(PhoenixWing156&MDJ)的支持,工作代码现在看起来像这样

$('.row-links').on('click', 'td:not(.special-td)', function(){


    //get the …
Run Code Online (Sandbox Code Playgroud)

jquery tablerow clickable

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

Braintree沙箱测试(伪随机数)

我正在测试Braintree沙箱(PHP),即使我使用的是伪随机数据,交易仍然显示有效

我有一个dropin前端和一个PHP后端

我的后端测试代码如下所示:

$amount = '12.00';
$nonce = 'fake-processor-declined-visa-nonce';
$result = Braintree_Transaction::sale(['amount' => $amount, 
                                       'paymentMethodNonce' => $nonce, 
                                       'options' => ['submitForSettlement' => true]
                                      ]);
$debug = get_object_vars($result);
print_r($debug);
Run Code Online (Sandbox Code Playgroud)

结果

Array
(
    [success] => 1
    [transaction] => Braintree\Transaction Object
        (
            [_attributes:protected] => Array
                (
                    [id] => 9bnyb32r
                    [status] => submitted_for_settlement
                    [type] => sale
                    [currencyIsoCode] => EUR
                    [amount] => 12.00
                    [merchantAccountId] => somenamehere
                    [subMerchantAccountId] => 
                    [masterMerchantAccountId] => 
                    [orderId] => 
                    [createdAt] => DateTime Object
Run Code Online (Sandbox Code Playgroud)

我保证这些假的小菜在沙箱中测试错误结果...还是我错过了一些东西

https://developers.braintreepayments.com/reference/general/testing/php#test-amounts

php sandbox braintree

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

Mysql - LEFT JOIN与COUNT

我有2个数据库表

  1. 目录
  2. directory_category

它们分别通过两个表中的类别ID(作为cat_id和id)链接


我想列出directory_category中的所有类别,同时计算在此类别的目录中找到多少条记录(使用单个sql查询)

我试过了

SELECT 
      directory_category.id
      directory_category.category_name
      directory.cat_id
      count(directory) as total_records
      FROM directory_category
      LEFT JOIN directory
      ON directory_category.id = directory.cat_id
Run Code Online (Sandbox Code Playgroud)

此查询仅生成一条记录,而total_records似乎是整个目录表的总和

mysql

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

标签 统计

braintree ×1

clickable ×1

jquery ×1

mysql ×1

php ×1

sandbox ×1

tablerow ×1