Mailchimp mc:hideable hides the wrong section within repeatable block - email

I've built a custom mailchimp template and added repeatable and hideable sections so my client can edit it more easily. I have read all the documentation, my code validates, and the email itself functions great, except for one problem. Here's the gist of my layout - and ideally how I would like it to work (all extraneous code removed - but I can supply it separately if needed).
<table mc:repeatable>
<tr>
<td><img src="" alt="article image"></td>
</tr>
<tr>
<td>
<h2 mc:edit="article_title" mc:hideable>Optional Title</h2>
<div mc:edit="article_body" mc:hideable>Optional content</div>
</td>
</tr>
<tr>
<td>
<div mc:edit="article_button" mc:hideable>Optional Styled Button</div>
</td>
</tr>
</table>
When I go into the campaign editor, I can hide sections successfully. UNTIL I duplicate the block. Once I have 2 blocks, and I hide the 1st block's h2, it hides the following div. If I hide the div, it hides the button. Note: within campaign editor it appears to hide things properly. Only when I preview the email can I see that it's hiding the wrong sections.
I have tried every variation I can think of:
Nesting tables for each piece of hideable content
Separating the edit and hideaable tags to parent/child elements
Renaming all the mc:edit attributes
Moving mc:repeatable to the tr or nested tables instead
Removing mc:hideable completely, except for the button (So they would delete copy rather than hiding the whole section.)
Item 5 above resulted in a completely different problem. When I duplicated the block and hid the button on the replicated block, it hid the button in the FIRST section. It's like the names are getting crossed somehow.
There's gotta be something I'm missing. Mailchimp's documentation seems really straightforward and I haven't been able to find anything about this specific issue.
Thanks in advance!

As a workaround instead of creating mc:hideable elements inside the mc:repeatable block I've created multiple variants using mc:variant, and each variant has different items inside it.
So in your example your varients would be:
Block
Block with title
Block with content
Block with button
Block with title and content
Block with title and button
Block with title and content and button
Block with content and button
This is not quite as neat as a solution but it does work.
See here for mc:variant syntax.

Related

jQuery Toggle in SharePoint using XSLT, but all the instances toggle not just the clicked one

I am having a problem with my XSLT, I am using SharePoint 2010 and I am building a custom front-end that will pull data from lists and render the data in a nice manner. I have figured out how to use XSLT with HTML to render a SharePoint list, I wasn't able to add an image of my news feeds because my rep is too low but I will get it up!
Now here is where my problem starts:
I am using jQuery toggle to show/hide the body paragraph of this news feed. The Continue Reading button is where my issue is, every time I click on the "Continue Reading" button in the lower right of each news post, it show/hides all the news items, not just the one I click on.
I have tried using Bootstrap collapse and now I am using jQuery Toggle() however I run into the same issue! Take a look at my XSLT code snippet to display thee body paragraph and the corresponding jQuery code snippet that actives the show/hide toggle:
XSLT:
<tr class="spacer">
<td valign="top" class="td-newscontent">
<div class="news content">
<!-- start excerpt -->
<xsl:value-of select="#BodyExcerpt" disable-output-escaping="yes" />
<div class="moving">
<xsl:value-of select="#Body" disable-output-escaping="yes" />
</div>
<!-- end news excerpt -->
<!-- start continue reading link -->
<xsl:text disable-output-escaping="yes"><![CDATA[<br class="continue-br" />]]></xsl:text>
<a class="butt pull-right continue-right">Continue Reading</a><br /><br />
<!-- end continue reading link -->
</div>
</td>
</tr>
Javascript (jQuery)
$(".moving").hide();
$(".butt").click(function() {
$(".moving").toggle("slow", function() {
});
});
.moving is the actual #body being shown/hidden
.butt is the "continue reading" button (I know butt was a bad name to use)
I have read a few things on the net about "this" but I am not sure how to use it.
First time posting so I couldn't post any images, but when you click on "continue reading" all the body news articles expand then you click it again and all the body news items contract, what I would like it to do is open just the one I am clicking on!
I have a lot going on, everything is housed in SharePoint, using HTML5, Css3, jQuery and XSLT. I started by using IDs but I switched to classes, not sure if that was a good idea but it functions, but not as intended.
Any help would be appreciative, I have been researching this issue for almost 2 weeks so I finally decided to ask some experts :) (Feel free to ask any questions or ask for more information, I will answer with everything I got!)
You are close, so well done for getting this far! Your problem lies in your JavaScript. If you look at the rendered code using your browser's developer tools (F12), you will find that all of the different body texts have the same class (moving) and all of the buttons have the same JavaScript onclick, which is to toggle everything of class .moving.
Thus the solution you are looking for is to match each button with its respective body text. There are two main ways you can do this.
You can give each text div and each button a unique ID by assigning it to some unique feature of the list item (SharePoint list items already have a unique identifier as the field ID). Using xsl:value-of within HTML attributes would violate XML rules, so you can use something called an Attribute Value Template, which is the bit in the curly braces:
<div id="newstext_{#ID}">
<xsl:value-of select="#Body" disable-output-escaping="yes" />
</div>
<!-- etc... -->
<a onclick="$('#newstext_{#ID}').toggle('slow', function() {});">Continue reading</a>
Modify just the JavaScript to target the parent of the button. The following code selects the parent DOM element of the button, which should be the div of class .news, then finds the child of class .moving, then applying your toggle:
$(".butt").click(function() {
$(this).parent().find(".moving").toggle("slow", function() {
});
});
The second method is easier but can get complicated if you end up running a lot of JavaScript. It is easier (and more efficient) to select elements by ID, so personally I think the extra effort is worth it. I haven't tested this code so let me know if it doesn't work. On some of your other points:
no, butt is not a good name for a class - remember, you can use element types in your jQuery selectors, so there is no need to duplicate the type as the class. For example, $('a') selects all the anchor tags on the page.
IDs should be used when elements need to be uniquely identified (e.g. for scripts), classes when you are grouping elements together (e.g. for styles).

No validation working on the form inside the jQuery UI dialog

No validation plugin is working on the form contained inside a jquery Ui dialog box. Using Bassistance jQuery validation plugin, works great out of the ui modal box, no luck working it on the form contained inside the jQuery Ui modal box, nor the validate.js method is working. What might be wrong? Almost pulling hair out for this
Ok, this was not a jquery or any js problem.
The html was not formated properly, the form element was "inside" a table which didnot work,
always have form element enclose a table
<form>
<table>
<tr>
<td><!--input element here--></td>
</tr>
</table>
</form>
and not
<table>
<form>
<tr>
<td><!--input element here--></td>
</tr>
</form>
</table>
If you are enclosing form inside a table cell, it should be ok.

jQuery Selector Help Next Class

Im stuck on something and although there is 1000 different ways to select what I need, I cant get it going.
In the HTML below, the <tr class="hide"> is hidden, and when someone clicks the link in the span, I want it to slidedown.
I've tried
$(this).parent().next().slideToggle('slow');
and a bunch of other similar things, but no love. It seems because the hidden tr element is down 2 levels I cant select it.
Mind you, there will be multiple of these on a page, it needs to be the next one in line that slides down, so I cant just $('.hide') select it.
Can someone help?
Heres my HTML
<td>
<span class="details">Details</span>
</td>
</tr>
<tr class="hide">
<td></td>
Try to
$(this).closest('tr').next().slideToggle('slow');
Assuming that the code you wrote is being triggered when a user clicks the span, then your code is not going high enough up the DOM to get to the next TR. What you need is this:
$(this).parent().parent().next().slideToggle('slow');
The first parent() gets you to the <td>, and the second one gets you to the <tr>.

Using mshtml to set contentEditable, prevent selecting div

My current project involves working with a document editor that, for better or worse, is implemented using mshtml and setting contentEditable to true. We're certainly considering replacing this setup with something else, but for the moment assume it is not an option.
In case it matters, we're doing this using VS 2008 (.Net 3.5) & C#:
document = (HtmlDocument)this.editorWebBrowser.Document;
body = (HtmlBody)document.body;
body.contentEditable = true;
We'd like to hide most of the structural editing behind our UI, but let the user edit the text any way they like. The problem arises when we add a div with any of several styles:
(Adding a body tag to simulate what we're doing programmatically, so you can test in IE, but remember we're working in C#/.Net/VS.)
<BODY contentEditable="true">
<DIV class="intro" style="border: 1px solid blue; width=100%;">
<P>My Intro</P>
</DIV>
<P>Other Text</P>
</BODY>
There are two things wrong with this:
The first click by the user selects the div. We'd like the click to go straight to the text, and never let the user see the resize handles.
If the user places the cursor in Other Text then tries to move to the div text using the keyboard, they're prevented. The div is treated as one character when you are outside of it moving around.
So, effectively, is there any way to make the div behave like just a background decoration, but have everything around it still be editable? This html is completely internal, so we can do anything with it we like. So the div itself doesn't matter. What matters is that we:
Contain several P or other tags
Show the user visually that all the contained P or other tags are part of one group, as styling like border & background color on the current div accomplish now.
This SO question makes me worried that what I want isn't possible with our current setup, but I ask to help anyone else who stumbles on a similar problem. I'll be adding a couple imperfect solutions we've come up with in a moment.
Possible or not, thanks for any thoughts you might have.
Partial solution: Set a containing div to contentEditable=false, then true again on an inner element, like so:
<BODY contentEditable="true">
<DIV class="intro" contentEditable="false" style="border: 1px solid blue; width=100%;">
<P contentEditable="true">My Intro</P>
</DIV>
<P>Other Text</P>
</BODY>
This possibly solves problem 1 (user selecting the div) but does nothing about problem 2.
Since the HTML is internal and doesn't need to play nice with anything else, just represent the area with a table, rather than a div:
<table class="intro">
<tbody>
<tr>
<td>
Intro
</td>
</tr>
</tbody>
</table>
This solves both problems, but significantly complicates the code for editing or parsing. We'd prefer a cleaner solution.

changes in the article display in joomla

I am trying to get all the articles that I have included to appear on the front page. I have published all of them and also enabled the Front Page column for each of them . But the problem is that one of the articles (say 'main article') occupy the entire width and the others appear side by side. I want of all them to appear taking up the entire width.
<table>
<tr><td>Main article</td></tr>
<tr><td>Sub Article1</td>
<td>Sub Article2</td>
</tr>
<tr><td>Sub Article3</td>
<td>Sub Article4</td>
</tr>
</table>
but i need them to appear as
<table>
<tr><td>Main article</td></tr>
<tr><td>Sub Article1</td></tr>
<tr><td>Sub Article2</td></tr>
<tr><td>Sub Article3</td></tr>
<tr><td>Sub Article4</td></tr>
</table>
is this question relevant and able to be understood...
Please help me out..
You need to setup this in the Menu section. Go to Menu → [Menu where your Front Page assigned]
Than choose menu thread, that response to your Front Page and in it's setup set number of columns to 1 or 0. Thats may help.