Click here to Skip to main content
12,452,251 members (54,239 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: jquery-ui
Hi,

Is it possible to disable JQuery UI accordion headers in JQ UI 1.8 , so i cant open them? For example i have step 1 till step 4. And i can only open step 2 if i saved step 1.
$(function() {
    var icons = {
           header: "h3",
           activeHeader: "ui-icon-circle-arrow-s"
    };
       $( "#prod_accordion" ).accordion({
           active:<?php echo $db_obj->getValue('status') ? 'acc_'.$tab_status : 'acc_0'; ?>,
           icons: icons,
           autoHeight: false,
           change: function(event, ui) {
               var newIndex = $(ui.newHeader).index('h3');
               if (jQuery.inArray(newIndex , accordion_array) == -1) {
                   var oldIndex = $(ui.oldHeader).index('h3');
                   $(this).accordion('activate' , oldIndex);
               }
           }
 
       });
   });
Posted 21-Nov-12 4:00am
T0mii604
Updated 29-Nov-12 20:10pm
v2
Comments
Sk. Tajbir 21-Nov-12 10:17am
   
Can you share your code ?
Ed Nutting 21-Nov-12 11:20am
   
Yes. Now work out how :)

You didn't indicate that you had actually tried to solve this yourself, so you shouldn't be expecting anything more than a "yes" or "no" answer...

Ed
G0geta 21-Nov-12 11:22am
   
ofc i post it tomorrow in the morning no problem. :)
G0geta 22-Nov-12 3:53am
   
[Moved by OP to the question — SA]
Sergey Alexandrovich Kryukov 28-Nov-12 18:02pm
   
Could you move it to your question where you can format it properly with HTML tag "pre"? Use Improve question...
--SA
G0geta 30-Nov-12 2:10am
   
moved
Sergey Alexandrovich Kryukov 30-Nov-12 13:29pm
   
Thanks. Let me see...
--SA
G0geta 27-Nov-12 3:38am
   
anny suggestions? :)

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

I found a way and i thought ill share it hopefully it will help some one else a lot. Smile | :)

$(function() {
    var icons = {
           header: "h3",
           activeHeader: "ui-icon-circle-arrow-s"
    };
       $( "#prod_accordion" ).accordion({
           active:<?php echo $db_obj-?>getValue('status') ? 'acc_'.$tab_status : 'acc_0'; ?>,
           icons: icons,
           autoHeight: false,
           beforeActivate: function(event, ui) {
               var newIndex = $(ui.newHeader).index('h3');
               if (jQuery.inArray(newIndex , accordion_array) == -1) {
                   event.preventDefault();
               }
           }
 
       });
   });

the accrodion_array is an array with indexes like (1,2,3,4) and i check if the index of the clicked accordion lets say 5 is in the array. If not then perventDefault() and the accordion header wont open.

if u add
ui.addClass('ui-state-disabled');
to the accordion headers that are not in the array the user will now what accordion he cant open. Smile | :)
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 14 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100