Jump to content
  • 0

Всплывающий тултип не работает при выводе через ajax


mstdmstd
 Share

Question

Всем привет,
Есть 2 схожих кусочка кода ссылки с всплывающим тултипом:

<a data-toggle="tooltip" data-html="true" data-placement="top" title="" data-original-title="Has 2 back order items" class="info_waring a_link"><i class="fa fa-anchor" style="font-size:larger;"></i></a>
<a data-toggle="tooltip" data-html="true" data-placement="top" title="" data-original-title="The product is marked as <b>back order</b>." class="a_link"><i class="fa fa-anchor info_waring" style="font-size:larger;"></i></a>

Первый тултип отображается нормально, 2й не отображается, при том что он выводится через ajax :

jQuery.ajax({

url: "cart/load_cart_items",
type: 'GET',
dataType: 'json',
success: function(result) {

if (result.error_code == 0) {

$("#div_load_cart_items").html(result.html)

}

}

})

В этом ли причина и можно ли ее побороть?

Спасибо!

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

Так наверное содержимое нужно положить в атрибут data-original-title, или я не пойму?

$("#div_load_cart_items").data("original-title", result.html);

И я не вижу в разметке атрибут id="div_load_cart_items".

Link to comment
Share on other sites

  • 0

Видимо, я не очень удачно обьяснил.
Через вызов :

jQuery.ajax({



url: "cart/load_cart_items",
type: 'GET',
dataType: 'json',
success: function(result) {

if (result.error_code == 0) {

$("#div_load_cart_items").html(result.html)

}

}

...Выводится список и в коде ниже :

<div class="table-responsive">



<table class="table table-bordered table-hover table-striped">

<thead>
<tr class="padding_md">

<th></th>
<th>Product</th>
<th>Price</th>
<th>Quantity</th>
<th>Total</th>

</tr>
</thead>
<tbody>

<tr>

<td>

<a class="a_link" onclick="javascript:deleteCartItem(49)">

<img src="http://local-wprods.com/static/images/modern-business/delete.png" style="vertical-align:top; " >

</a>

</td>

<td>

<img src="http://local-wprods.com/uploads/products/-product-49/51t5p4hTuwL._SL1000_.jpg" alt="Dell S2240M 21.5-Inch Screen LED-lit Monitor" height="64px" width="64px">
<a href="http://local-wprods.com/price_list_details/dell-s2240m-21-5-inch-screen-led-lit-monitor" class="a_link" target="_blank">

<a data-toggle="tooltip" data-html="true" data-placement="top" title="The product is marked as back order" data-original-title="The product is marked as back order" class="a_link" ><i class="fa fa-anchor info_waring" style="font-size:larger;"></i></a> 
Dell S2240M 21.5-Inch Screen LED-lit Monitor :: N

</a>

</td>

<td style="text-align: right">$76.09</td>

<td>

<input step="1" min="1" max="9999" name="cart_product_qty_49" id="cart_product_qty_49" value="1" title="Qty" class="input-text qty text cart_product_qty" size="4" maxlength="4" pattern="[0-9]*" inputmode="numeric" type="number" style="max-width: 65px; text-align: right;" onchange="javascript:onChangeQty( '49', '76.09' )">

</td>

<td style="text-align: right"><span id="span_cart_product_subtotal_49" >$76.09</span></td>

</tr>
<tr>

<td>

<a class="a_link" onclick="javascript:deleteCartItem(54)">

<img src="http://local-wprods.com/static/images/modern-business/delete.png" style="vertical-align:top; " >

</a>

</td>

<td>

<img src="http://local-wprods.com/uploads/products/-product-54/71AsYKqngTL._SL1500_.jpg" alt="Dell E2016HV VESA Mountable 20" Screen LED-Lit Monitor" height="64px" width="64px">
<a href="http://local-wprods.com/price_list_details/dell-e2016hv-vesa-mountable-20-screen-led-lit-monitor" class="a_link" target="_blank">

Dell E2016HV VESA Mountable 20" Screen LED-Lit Monitor :: Y

</a>

</td>

<td style="text-align: right">$109.60</td>

<td>

<input step="1" min="1" max="9999" name="cart_product_qty_54" id="cart_product_qty_54" value="1" title="Qty" class="input-text qty text cart_product_qty" size="4" maxlength="4" pattern="[0-9]*" inputmode="numeric" type="number" style="max-width: 65px; text-align: right;" onchange="javascript:onChangeQty( '54', '109.6' )">

</td>

<td style="text-align: right"><span id="span_cart_product_subtotal_54" >$109.60</span></td>

</tr>

</tbody>

</table>

</div>

1й элемент имеет иконку якоря с тултипом:

<a data-toggle="tooltip" data-html="true" data-placement="top" title="The product is marked as back order" data-original-title="The product is marked as back order" class="a_link" ><i class="fa fa-anchor info_waring" style="font-size:larger;"></i></a> 

И этот тултип не виден, если список загружается через аджакс. По-моему, я ничего не упустил?

div_load_cart_items - это обычный див куда и вставляется список выше.

Link to comment
Share on other sites

  • 0

Попробуйте проиинициализировать тултипы после подгрузки контента:

jQuery.ajax({
  url: "cart/load_cart_items",
  type: 'GET',
  dataType: 'json',
  success: function(result) {
    if (result.error_code == 0) {
      $("#div_load_cart_items").html(result.html);
      $('[data-toggle="tooltip"]').tooltip();
    }
  }
});

 

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy