diff --git a/examples/index.html b/examples/index.html index cb9c3a3..2a926b5 100644 --- a/examples/index.html +++ b/examples/index.html @@ -144,6 +144,10 @@

Step 4 Content

} }); + $("#smartwizard").on("loaded", function(e) { + console.log("loaded"); + }); + // Smart Wizard $('#smartwizard').smartWizard({ selected: 0, diff --git a/src/js/jquery.smartWizard.js b/src/js/jquery.smartWizard.js index c6e3d84..34fd834 100644 --- a/src/js/jquery.smartWizard.js +++ b/src/js/jquery.smartWizard.js @@ -120,6 +120,7 @@ this._setPreviousStepsDone(idx); // Show the initial step this._showStep(idx); + this._triggerEvent("loaded"); } // Initialize options diff --git a/test/test.js b/test/test.js index 60fccc0..9b24c49 100644 --- a/test/test.js +++ b/test/test.js @@ -55,3 +55,21 @@ describe('SmartWizard Navigation', function() { }); }); + +describe('SmartWizard widget', () => { + it('should trigger "loaded" event', () => { + jasmine.getFixtures().fixturesPath = 'base/test'; + loadFixtures('test-template.html'); + + var loadedEventSpy = jasmine.createSpy("loaded"); + var el = $('#smartwizard'); + + $(el).bind("loaded", loadedEventSpy); + + expect(loadedEventSpy).not.toHaveBeenCalled(); + + el.smartWizard(); + + expect(loadedEventSpy).toHaveBeenCalled(); + }); +});