0

I am using a jquery plugin (smartwizard) to make a form wizard. The plugins automatically adds an attribute called "isdone" and a class called "done" on all links that appears in the form. This helps the plugin to know which form steps are completed. But it makes other links in the form malfunction due to the added classes. I want to remove the class and the attribute from some links.

I have this link:

<a href="sample.com" id="file_link">My link</a>

after page load the plugin adds the following attribute and class

<a href="sample.com" class="done" isdone="1" id="file_link">My link</a>   

Here is the code snippet that initializes the wizard, and what i tried:

jQuery(document).ready(function(){
 jQuery('#wizard').smartWizard({
 selected:1,
 enableAllSteps:false,
 transitionEffect:'slideleft',
 onLeaveStep:leaveAStepCallback,
 onFinish:onFinishCallback,
 onContinueLater:onContinueLaterCallback,
 enableFinishButton:false,
 });
 //
jQuery('#file_link').removeAttr('isdone');//doesn't work
    jQuery('#file_link').live(function(){
    jQuery(this).removeAttr('isdone');//doesn't work also
});
});

Any Ideas on how to solve this?

Tom Mwenda
  • 155
  • 3
  • 16
  • @C-Link. your suggestions and that of Latheesan Kanes works if tested with the plugin disabled and i try removing an arbitrary attribute. But will break the moment it's enabled. I added the code after initializing the wizard. Coz my little knowledge tells me that the attributes are added after the plugin completes it's execution..still cant figure out why these codes wont work. Any more suggestions are will be greatly appreciated – Tom Mwenda Oct 29 '13 at 09:41

3 Answers3

1

Add the code into document ready function.

$(document).ready(function()
{
    setTimeout(function() {
        var myAttr = $('#file_link').attr('isdone');
        if (typeof myAttr !== 'undefined' && myAttr !== false) {
            $('#file_link').removeAttr('isdone');
        }
    }, 250);
});
Latheesan
  • 23,247
  • 32
  • 107
  • 201
  • I have tried this and doesn't work, this is because the only difference between your suggestion and mine is that you have added a check for myAttr. – Tom Mwenda Oct 29 '13 at 09:27
  • could be an issue with another document ready script getting executed after yours. Try adding a small delay. See my updated answer. – Latheesan Oct 29 '13 at 09:40
  • @Latheesan Kanes Oh thanks, works now. I hadn't checked you update – Tom Mwenda Oct 29 '13 at 09:48
0

Try this:

jQuery('#file_link').on('load',function(){
jQuery(this).removeAttr('isdone');
});
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231
0

Add your removeAttr script at your footer section after all the scripts.

Manikandan
  • 590
  • 2
  • 4
  • 13