You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
alert('Would have gone to the Profile linked in `href`, but preventDefault stopped it.');
320
-
}
321
-
},
322
-
{
323
-
text:'Shopping Cart (1)',
324
-
href:'https://www.domain.com/cart/'
325
-
},
326
-
{
327
-
text:'Orders (0)',
328
-
href:'https://www.domain.com/orders/'
329
-
},
330
-
{
331
-
text:'Documents',
332
-
href:'https://www.domain.com/documents/'
333
-
},
334
-
],
335
-
callback: (elem, meta, data) => {
336
-
console.log(elem, meta, data);
337
-
}
338
-
},
339
-
{
340
-
position:'bottom',
341
-
primaryText:'Sign Out',
342
-
href:'https://www.domain.com/logout/',
343
-
onclick: (e) => {
344
-
e.preventDefault();
345
-
alert('Hello World!');
346
-
},
347
-
callback: (elem, meta, data) => {
348
-
console.log(elem, meta, data);
349
-
}
350
-
}]);
351
-
})(window.DDC.APILoader);
352
-
```
353
-
354
-
The `insertMenuContent` method allows you to add custom items to the primary navigation menu of Dealer.com sites. You can specify where the items should appear, the primary and secondary text for each item, and any sub-items that should be displayed when the main item is expanded.
355
-
356
-
The `target` parameter specifies the navigation menu to target. The only currently supported value is 'primary-menu'.
357
-
358
-
The `arrayOfObjects` parameter is an array of objects describing the menu items to be inserted. Each object can include the following properties:
359
-
360
-
Property | Description
361
-
-------------- | --------------
362
-
`position` | The location where the item should be inserted in the menu. The supported values are `top` and `bottom`.
363
-
`primaryText` | The main text for the menu item.
364
-
`secondaryText` | Additional text that appears beneath the primary text in the menu item.
365
-
`href` | The URL where the user should be directed when they click the menu item.
366
-
`subItems` | An array of sub-menu items that appear when the main item is expanded. Each sub-item can include the `text` and `href` properties, as well as an `onclick` property specifying a function to be executed when the sub-item is clicked.
367
-
`callback` | A function to be called after the menu item has been inserted. This function is passed three parameters: the newly-inserted HTML element (`elem`), the 'page event' object (`meta`), and the original data passed to the `insertMenuContent` function (`data`).
368
-
`expanded` | A boolean value indicating whether the menu item should be expanded to show any sub-items when the page loads. The default value is `false`.
369
-
`menuIcon` | A boolean value indicating whether an icon should be displayed next to the menu item. The default value is `false`.
370
-
371
-
The `callback` function you specify is called with three parameters:
372
-
373
-
Name | Description
374
-
-------------- | --------------
375
-
`elem` | `{HTMLElement}` The newly-inserted HTML element.
376
-
`meta` | `{object}` The 'page event' object. For more information, see the [page event documentation](https://dealerdotcom.github.io/web-integration-api-docs/#page-event).
377
-
`data` | `{object}` The original data you passed to the `insertMenuContent` function.
378
-
379
-
In addition to inserting static content, you can also add interactive functionality to the menu items by providing `onclick` functions. For example, you can prevent the default link behavior and display an alert message when a menu item is clicked, as demonstrated in the example code.
0 commit comments