Embedded magicrepeats

Discussion about MagicEdit features, modules, applications, and HowTos.

Embedded magicrepeats

Postby kosborn » Tue Aug 21, 2012 8:39 am

Is it possible to have a magicrepeat inside a magicrepeat? See code below. The problem, when I do this, is that when I try to make a new categoryheading, it grabs and copies all the subcategories. And then when I change one it changes the same element on the one above. See http://iconsafe.free.magicedit.com/editmenu.html to see it in action.

<magicrepeat me_name="CategoryGroup" me_repeat="no">
<li><a href="category.html"><span><magicedit me_name="CategoryHeading" me_repeat="no" me_plain>Category Head</magicedit></span></a>
<ul class="subNav2">
<magicrepeat me_name="SubCategories" me_repeat="no" >
<li><a href="category.html"><magicedit me_name="SubCategoryLink" me_plain>SubCategory Link</magicedit></a></li>
</magicrepeat>
</ul>
</li>
</magicrepeat>
kosborn
 
Posts: 77
Joined: Wed Sep 14, 2011 2:02 pm

Re: Embedded magicrepeats

Postby raw10 » Tue Aug 21, 2012 9:00 am

kosborn wrote:Is it possible to have a magicrepeat inside a magicrepeat? See code below.


By default, magicrepeats do not nest. They all "live" at the top level, so setting me_repeat="no" on them does nothing (that's the default state). If you want to nest repeats, use me_repeat="yes" like this:

Code: Select all
<magicrepeat me_name="CategoryGroup">
  <li><a href="category.html"><span><magicedit me_name="CategoryHeading" me_plain>Category Head</magicedit></span></a>
    <ul class="subNav2">
      <magicrepeat me_name="SubCategories" me_repeat="yes" >
        <li><a href="category.html"><magicedit me_name="SubCategoryLink" me_plain>SubCategory Link</magicedit></a></li>
      </magicrepeat>
    </ul>
  </li>
</magicrepeat>


Also, setting me_repeat="no" on magicedit elements will break them out of the repeat entirely. It's setting it to a global value rather than one that's unique to its parent repeat. You'll notice that I removed it from the CatetoryHeading magicedit tag. You want the SubCategories to be unique to the parent repeat, so you must set me_repeat="yes" in this case.

Hope that helps!
raw10
 
Posts: 81
Joined: Tue Apr 12, 2011 2:46 pm

Re: Embedded magicrepeats

Postby kosborn » Tue Aug 21, 2012 11:29 am

Hi

That seems to fix it. I have trouble remembering what me_repeat actually means as its a little counterintuitive to me (the term). So I just try & copy old code from other ME sites. But changing it worked so I am good now. Thank you.
kosborn
 
Posts: 77
Joined: Wed Sep 14, 2011 2:02 pm


Return to MagicEdit Discusson

Who is online

Users browsing this forum: No registered users and 1 guest

cron