Members
-
componentName :String
-
Description
A unique name that identifies the component. Use the component name when getting a component, for example,
application.getComponent(componentName).Details
-
application :ComponentContainer
-
Description
The name which identify this kind of component. This name is used both for registering a new component and
getting a component implementation with ComponentContainerDetails
Methods
-
closeMessage( messageId )
-
Description
Lets you close a message on the page. To close a message, you must have the ID of the message, as returned by showMessage() when the message was shown.
var layout = container.getComponent('Layout'); var message_vat_no; if (layout) { // Check if a VAT number was entered. If not, display a message. if ($('#vat_no').val() == '') { message_vat_no = layout.showMessage({message: 'You must enter a VAT number to register as a business customer.', type: 'error'}); } } // Clear the VAT number error message when the VAT number field gets focus. $('#vat_no').focus(function() { layout.closeMessage(message_vat_no); });Parameters
Name Type Description messageIdstring The ID of the message to close. Get the ID of a message by assigning the return value of
showMessage()to a variable. -
setChildViewIndex( view_id, placeholder_selector, view_name, index ) → {void}
-
Description
Changes the position of a child view inside a container.
Parameters
Name Type Description view_idstring The identifier of the view of the current component that contains the child view whose position will be changed.
placeholder_selectorstring The identifier of a location in the specified view (view_id) where the child view will be added.
view_namestring The identifier of a view in the placeholder.
indexnumber The index of the child view's position.
Returns
Throws
-
showMessage( data ) → {string}
-
Description
Shows a message in the notifications area of a SuiteCommerce page. The message is displayed by default in the Notifications placeholder (a DIV element in the base theme template with the custom data attribute
data-view="Notifications"). You can display display the message in any other placeholder that uses the custom data attributesdata-viewordata-cms-area.Messages can be closed by the user, by setting a timeout in the method, or with the closeMessage() method. If you want to use
closeMessage(), first assign the return value ofshowMessage()to a variable, and then pass the variable tocloseMessage().In the following example, the message is shown and then closed after 5 seconds by setting a timeout.
var layout = container.getComponent('Layout'); if (layout) { var message_shown = false; layout.on('afterShowContent', function() { if (message_shown != false) { layout.showMessage({ message: '', type: 'info', selector: 'Notifications', timeout: 5000 }); message_shown = true; } }); }In the following example, a message is shown if an invalid VAT number is entered. When the user enters a valid number, the message is closed.
var layout = container.getComponent('Layout'); var message_vat_no; $('#vat_number').blur(function() { var vat_number = $(this).val(); if (message_vat_no !== undefined) { layout.closeMessage(message_vat_no); } // checkVatNumber() returns false if the number entered is invalid. if (!checkVatNumber(vat_number)) { message_vat_no = layout.showMessage({ message: 'You must enter a VAT number to register as a business customer.', type: 'error' }); } });Parameters
Name Type Description dataObject Data required to display the message.
datais an object, which can have the following properties:- message - Required. The text of the message.
- type - Required. The type of message. It also determines the appearance of the message on the page. Type can be one of the following:
info,warning,error, orsuccess. - selector - A placeholder on the page where you want the message to appear.
- timeout - Specifies the duration in milliseconds of the message on the page. If you do not specify a timeout, you can use closeMessage() to remove the message.
Returns
Details
-
addChildViews( view_id, child_views ) → {void}
-
Description
Adds one or more child views to an existing view. The existing view must already be in the DOM and must have the 'data-view' HTML attribute.
The
addChildViewsmethod is flexible, but more complex thanaddChildView. Use the simpler addChildView() where possible.checkout.addChildViews( checkout.WIZARD_VIEW , { 'Wizard.StepNavigation': { 'CheckoutView': { childViewIndex: 1 , childViewConstructor: function () { return new CheckoutExtensionView({checkout:checkout}); } } } } );Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the child views will be added.
child_viewsobject Returns
Throws
-
addChildView( view_id, childViewConstuctor ) → {void}
-
Description
Adds a child view to an existing View which is already appended in the DOM with the given
data-viewHTML attribute.EXAMPLE
checkout.addChildView('Wizard.StepNavigation', function () { return new CheckoutExtensionView({checkout:checkout}); });Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the child view will be added.
childViewConstuctorSimpleChildViewConstructor The identifier of the location in the specified view (view_id) where the child view will be added.
Returns
Throws
-
removeChildView( view_id, placeholder_selector [, view_name ] ) → {void}
-
Description
Removes a child view from a view.
Parameters
Name Type Attributes Description view_idstring The identifier of the view of the current component from which the child view will be removed.
placeholder_selectorstring The identifier of the location in the specified view (view_id) from which the child view will be removed.
view_namestring <optional> The identifier of the view to be removed.
Returns
Throws
-
addToViewContextDefinition( view_id, property_name, type, callback ) → {void}
-
Description
Adds a property to the UI context of a view to extend interaction with its template.
Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the context property will be added.
property_namestring The name of the property.
typestring The type of the property. The value returned by the callback function must be of the same type.
callbackfunction A function that sets the value of the property (property_name).
Returns
Throws
-
removeToViewContextDefinition( view_id, property_name ) → {void}
-
Description
Removes a property from the UI context of a view.
Parameters
Name Type Description view_idstring The identifier of the view of the current component from which the context property will be removed.
property_namestring The name of the property.
Returns
Throws
-
addToViewEventsDefinition( view_id, event_selector, callback ) → {void}
-
Description
Adds an event handler to an event in a view.
Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the event handler will be added.
event_selectorstring callbackfunction The event handler function to call when the specified event occurs.
Returns
Throws
-
removeToViewEventsDefinition( view_id, event_selector ) → {void}
-
Description
Removes an event handler from an event in a view.
Parameters
Name Type Description view_idstring The identifier of the view of the current component to which the event handler will be added.
event_selectorstring Returns
Throws
-
extend( componentDefinition ) → {BaseComponent}
-
Description
Extends the current component and creates a child component.
Parameters
Name Type Description componentDefinitionObject An object with the appropriate properties and methods to create the component.
Returns
Details
-
on( event_name, handler ) → {void}
-
Description
Attaches an event handler to an event name. Alias for CancelableEvents#cancelableOn.
Parameters
Name Type Description event_nameString The name of the event to attach to
handlerfunction Returns
Details
-
off( event_name, handler ) → {void}
-
Description
Detaches an event handler from an event name. Alias for CancelableEvents#cancelableOff.
Parameters
Name Type Description event_nameString The name of the event from which to detach the event handler.
handlerfunction Returns
Details
-
cancelableOn( event_name, handler ) → {void}
-
Description
Attaches an event handler to an event.
Parameters
Name Type Description event_nameString The name of the event to which the event handler will be attached.
handlerfunction The event handler method that will be invoked when event_name is triggered. This function can receive optionally one parameter representing the action parameter. Besides optionally can return a Deferred to details the execution of the trigger's callback. If the returned Deferred is rejected the trigger's callback wont be called
Returns
Details
-
cancelableOff( event_name, handler ) → {void}
-
Description
Detaches an event handler from an event.
Parameters
Name Type Description event_nameString The name of the event from which to detach the event handler. This argument is required.
handlerfunction The event handler that will be removed from the list of handlers attached to the event. This argument is required.
Returns
Details
-
cancelableDisable( event_name ) → {void}
-
Description
Disables all the event handlers attached to an event.
Parameters
Name Type Description event_nameString The name of the event.
Returns
Details
-
cancelableEnable( event_name ) → {Void}
-
Description
Re-enables all the event handlers attached to an event.
Parameters
Name Type Description event_nameString The name of the event.
Returns
Details
-
cancelableTrigger( event_name, ...args ) → {Deferred}
-
Description
Triggers an event with a set of arguments. If an event handler is rejected, the event handler callbacks will not be executed.
Parameters
Name Type Attributes Description event_nameString The name of the event to trigger.
argsparams <repeatable> One or more arguments that will be broadcast to all event handlers attached to the event.
Returns
Details
-
cancelableTriggerUnsafe( event_name, ...args ) → {Deferred}
-
Description
Triggers an event with a set of unsanitized arguments. If an event handler is rejected, the event handler callbacks will not be executed.
Parameters
Name Type Attributes Description event_nameString The name of the event to trigger.
argsparams <repeatable> One or more arguments that will be broadcast to all event handlers attached to the event.
Returns
Details