Pogledajte određenu poruku
Staro 22. 03. 2007.   #4
Ilija Studen
Direktor Kombinata
Invented the damn thing
 
Avatar Ilija Studen
 
Datum učlanjenja: 07.06.2005
Poruke: 2.669
Hvala: 44
119 "Hvala" u 64 poruka
Ilija Studen će postati "faca" uskoroIlija Studen će postati "faca" uskoro
Default

Sorry što se svađam sam sa sobom ali kod gore ima jednu grešku pa da ne bude kako širim dezionformacije Naime, stari kod izvuče SVE podelemente i strpa ih u novi DIV ignorišući strukturu. U tom kodu će:

Kôd:
<p>Hello <b>there</b>.</p>
Biti transformisano u:

Kôd:
<p>Hello .</p>
<b>there</b>
No, evo ga fix. Mnogo je jednostavnije IMO:

Kôd:
jQuery.fn.collapsible = function() {
  return this.each(function() {
    var fieldset = jQuery(this);
    var legend = fieldset.find(':first');
    var body = jQuery(document.createElement('div'));
    
    var children = fieldset.children();
    var len = children.length;
    if(len > 1) {
      for(i = 1; i < len; i++) {
        body.append(children[i]);
      } // for
    } // if
    
    body.addClass('collapsibleFieldsetBody');
    legend.addClass('collapsibleFieldsetTitle');
    
    legend.after(body);
  });
  
  return this;
}

Poslednja izmena od Ilija Studen : 22. 03. 2007. u 15:23.
Ilija Studen je offline   Odgovorite uz citat