• 14-08-2013, 17:47:24
    #1
    1/2
    HTML-Kodu:
    <link rel="stylesheet" href="css/style.css">
        <script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js'></script>
        <script src="js/organictabs.jquery.js"></script>
        <script>
            $(function() {
        
                $(".example-one").organicTabs({
                    "speed": 200
                });
        
            });
        </script>
    <pre><script type="text/javascript">// <![CDATA[
    $(document).ready(function(){
        var counter = 3;
        $("#addButton").click(function () {
        <!-- en fazla kaç tane text kutusu oluşturulabilir -->
        if(counter>10){
                alert("En fazla 10 tane");
                return false;
        }
        var newTextBoxDiv = $(document.createElement('div'))
             .attr("class", 'TextBoxDiv' + counter);
        <!-- text kutusunun eklendigi HTML kodları -->
        newTextBoxDiv.after().html( '<div class="example-one"><ul class="nav"><li class="nav-one"><a href="#featured" class="current">Featured</a></li><li class="nav-two"><a href="#core">Core</a></li><li class="nav-three"><a href="#jquerytuts">jQuery</a></li><li class="nav-four last"><a href="#classics">Classics</a></li> </ul><div class="list-wrap"><ul id="featured">1asdasd</ul> <ul id="core" class="hide" style="position: relative; top: 0px; left: 0px; display: none;"> 1asdasd</ul> <ul id="jquerytuts" class="hide" style="position: relative; top: 0px; left: 0px; display: none;">1 asdasfdsafgdsa43q</ul><ul id="classics" class="hide" style="position: relative; top: 0px; left: 0px; display: none;">1asdfsadfdsaf </ul></div> </div>');
        newTextBoxDiv.appendTo("#TextBoxesGroup");
        counter++;
         });
         $("#removeButton").click(function () {
        if(counter==1){
              alert("No more textbox to remove");
              return false;
           }
        counter--;
            $(".TextBoxDiv" + counter).remove();
         });
         $("#getButtonValue").click(function () {
        var msg = '';
        for(i=1; i<counter; i++){          msg += "\n Textbox #" + i + " : " + $('#textbox' + i).val();  }         alert(msg);      });   });
    // ]]></script></pre>
    <div id="TextBoxesGroup">
    	<div class="TextBoxDiv1">
    			<div class="example-one"><ul class="nav"><li class="nav-one"><a href="#featured" class="current">Featured</a></li><li class="nav-two"><a href="#core">Core</a></li><li class="nav-three"><a href="#jquerytuts">jQuery</a></li><li class="nav-four last"><a href="#classics">Classics</a></li> </ul><div class="list-wrap"><ul id="featured">1asdasd</ul> <ul id="core" class="hide"> 1asdasd</ul> <ul id="jquerytuts" class="hide">1 asdasfdsafgdsa43q</ul><ul id="classics" class="hide">1asdfsadfdsaf </ul></div> </div>
    	</div>
    		<div class="TextBoxDiv2">
    			<div class="example-one"><ul class="nav"><li class="nav-one"><a href="#featured" class="current">Featured</a></li><li class="nav-two"><a href="#core">Core</a></li><li class="nav-three"><a href="#jquerytuts">jQuery</a></li><li class="nav-four last"><a href="#classics">Classics</a></li> </ul><div class="list-wrap"><ul id="featured">1asdasd</ul> <ul id="core" class="hide"> 1asdasd</ul> <ul id="jquerytuts" class="hide">1 asdasfdsafgdsa43q</ul><ul id="classics" class="hide">1asdfsadfdsaf </ul></div> </div>
    	</div>
    </div>
    <pre><input id="addButton" type="button" value="Ekle" />
    <input id="removeButton" type="button" value="Sil" />
    <input id="getButtonValue" type="button" value="Text kutulari goster" />
    Elimiz ile birden fazla tab oluşturduğumuzda yukarıdaki gibi hiçbir sıkıntı yok ama dinamik olarak jQuery tab oluşturduğumuzda yeni oluşan tablar çalışmıyor.

    Üzerinde uzunca süre çalıştım ancak cevabı bulamadım farklı bir gözden bakmak faydalı olacaktır yardımcı olursanız sevinirim arkadaşlar



    (function($) {
    
        $.organicTabs = function(el, options) {
        
            var base = this;
            base.$el = $(el);
            base.$nav = base.$el.find(".nav");
                    
            base.init = function() {
            
                base.options = $.extend({},$.organicTabs.defaultOptions, options);
                
                // Accessible hiding fix
                $(".hide").css({
                    "position": "relative",
                    "top": 0,
                    "left": 0,
                    "display": "none"
                }); 
                
                base.$nav.delegate("li > a", "click", function() {
                
                    // Figure out current list via CSS class
                    var curList = base.$el.find("a.current").attr("href").substring(1),
                    
                    // List moving to
                        $newList = $(this),
                        
                    // Figure out ID of new list
                        listID = $newList.attr("href").substring(1),
                    
                    // Set outer wrapper height to (static) height of current inner list
                        $allListWrap = base.$el.find(".list-wrap"),
                        curListHeight = $allListWrap.height();
                    $allListWrap.height(curListHeight);
                                            
                    if ((listID != curList) && ( base.$el.find(":animated").length == 0)) {
                                                
                        // Fade out current list
                        base.$el.find("#"+curList).fadeOut(base.options.speed, function() {
                            
                            // Fade in new list on callback
                            base.$el.find("#"+listID).fadeIn(base.options.speed);
                            
                            // Adjust outer wrapper to fit new list snuggly
                            var newHeight = base.$el.find("#"+listID).height();
                            $allListWrap.animate({
                                height: newHeight
                            });
                            
                            // Remove highlighting - Add to just-clicked tab
                            base.$el.find(".nav li a").removeClass("current");
                            $newList.addClass("current");
                                
                        });
                        
                    }   
                    
                    // Don't behave like a regular link
                    // Stop propegation and bubbling
                    return false;
                });
                
            };
            base.init();
        };
        
        $.organicTabs.defaultOptions = {
            "speed": 300
        };
        
        $.fn.organicTabs = function(options) {
            return this.each(function() {
                (new $.organicTabs(this, options));
            });
        };
        
    })(jQuery);
  • Sponsor Reklam
  • 24-08-2013, 10:20:47
    #2
    1/2
    öyle bir fonksiyon oluştur ve :
                function tabla() {
                    $(".example-one").organicTabs({
                        "speed": 200
                    });
                }
    $(document).ready(function(){
    hemen sonrasına ekle :
     tabla();
    bunun da hemen sonrasına ekle :
    newTextBoxDiv.appendTo("#TextBoxesGroup");
      tabla();

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319