Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I am seeing an extra div appearing on the teaser after I add something to my cart that is totally screwing up my theme. I seem to recall a discussion as to how to prevent an extra div from showing up but for the life of me I can't find it now (of course) does anyone have a clue as to how to correct this?
btw the div has no idea or additional classes but does have a style of display:block on it.
Comments
Comment #1
Christopher Riley CreditAttribution: Christopher Riley commentedI found an old post that talks about it but so far haven't figured out a fix.
https://api.drupal.org/api/drupal/includes!ajax.inc/function/ajax_comman...
Comment #2
Christopher Riley CreditAttribution: Christopher Riley commentedIt appears that this is a lovely behavior of the main ajax.js to keep things nice and clean. For the time being in a custom template I have wrapped the whole template with a div that has a class of display:inline-block on it. Its not pretty and would love to hear if others have ideas or suggestions, but it works for now.
Thanks all.
Comment #3
subhojit777@Chris The issue is with ajax_command_replace(). Will remove the extra newlines that comes from the template file, as suggested here: https://api.drupal.org/comment/32698#comment-32698. Will fix this issue soon. Thanks!
Comment #4
subhojit777After some research I found that the solution mentioned here https://api.drupal.org/comment/32698#comment-32698 does indeed removes the div wrapper. But I am still getting a div wrapper with
display: block
. Might be some other issue.Comment #5
Christopher Riley CreditAttribution: Christopher Riley commentedI appreciate you looking into it and it too has me perplexed. I was hoping to find the issue and whip up a patch for you but I need to get a site launched. I'll hopefully have time to revisit it later and or someone else will see something to correct it.
Thanks again.
Comment #6
subhojit777@Chris I looked into the issue for hours and was really confused. Everything is okay with the template that is shown through ajax_command_replace(), seems like ajax_command_replace() works like that only. Will try to figure out something soon, or will have to find some other way round. Apart from bug fixing I am also working on new features of this module. Will let you know if I find anything :) Thanks!
Comment #7
torgosPizzaPossibly related, patch needs review: #2416037: theme_html_tag doesn't check that div is missing a #value and incorrectly tries to self-close
Comment #8
subhojit777Comment #9
subhojit777Comment #10
subhojit777Comment #11
joelpittetIs this still happening after that fix mentioned in #7?
Comment #12
subhojit777Yes. Infact I am working on this issue right, and I guess I will be able to fix this. Will come up with a patch in few days or by this coming weekend :)
Comment #13
joelpittetOk cool, let us know the Steps to Reproduce so we can manually test, gladly test it out:)
Comment #14
matsjacobsson CreditAttribution: matsjacobsson commentedHi,
For me it was adding more divs due to the fact that the ajax_command_replace uses the theme function from a template file (that I have added extra divs to).
To get this to work I wrapped the whole template file (dc-ajax-shopping-cart.tpl.php after the
if($order && $quantity != 0):
function) with the ajax-shopping-cart-wrapper div instead of having it wrapping just the products_list_html.To remove the extra
<div style="display:block;">
I removed the new lines as suggestedI also removed the div selector in: div.ajax-shopping-cart-wrapper that seamed to mess upp the markup. (When doing ajax_command_replace i also usually use id instead of class if that is possible, but classes should work to ofcourse..)
/Mats
Comment #16
subhojit777The last commit will fix the issue. I am not using
ajax_command_replace()
anymore for replacing the cart content. I have introduced a new Ajax commanddc_ajax_add_cart_command_html()
that does the same thing asajax_command_replace()
, just it won't add an extra wrapper div with styledisplay: block
.The code needs to be optimized, and automated tests needs to be written. I will carry them out in another issue.
Comment #17
subhojit777Thanks @matsjacobsson for your suggestion. But using a separate Ajax command seems a cleaner approach here.