diff --git a/ModuleConfig.cfc b/ModuleConfig.cfc index d8366af..aac83a6 100644 --- a/ModuleConfig.cfc +++ b/ModuleConfig.cfc @@ -11,6 +11,10 @@ component { "autoRegisterInterceptor": true, "autoRegisterHelpers": true, "autoRegisterControllerDecorator": true, + "defaultViewArgs": { + "view": "main/index", + "module": "cbInertia" + }, "version": function() { return ""; } diff --git a/README.md b/README.md index e995ff7..3e80adc 100644 --- a/README.md +++ b/README.md @@ -30,8 +30,12 @@ box install cbInertia ``` By default, no configuration is needed. However, you can disable the automatic -registering of the `InertiaLifecycle` interceptor and/or the cbInertia application -helpers, if you wish. +registering of the `InertiaLifecycle` interceptor, the cbInertia application +helper, or the Controller decorator if you wish. You can also customize the +view arguments for Inertia events. + +The one setting you will likely modify is the `version` setting. You can read +more about it below. ``` // config/ColdBox.cfc @@ -40,6 +44,10 @@ moduleSettings = { "autoRegisterInterceptor": true, "autoRegisterHelpers": true, "autoRegisterControllerDecorator": true, + "defaultViewArgs": { + "view": "main/index", + "module": "cbInertia" + } "version": function() { return ""; } @@ -133,6 +141,22 @@ inertia.share( "user", function() { You can call `share` as many times as you need. +### Customizing the Inertia View + +The default view that ships with cbInertia suits most use cases. If you need +to use a different view for any reason, you can customize the view arguments +sent to the `setView` function using the `defaultViewArgs` setting. + +```cfc +moduleSettings = { + "cbInertia": { + "defaultViewArgs": { + "view": "custom/view/page" + } + } +}; +``` + ### Controller Decorator Inertia automatically registers a Controller decorator by default. This diff --git a/interceptors/InertiaLifecycle.cfc b/interceptors/InertiaLifecycle.cfc index 88df5c3..8da355e 100644 --- a/interceptors/InertiaLifecycle.cfc +++ b/interceptors/InertiaLifecycle.cfc @@ -1,10 +1,7 @@ component { property name="version" inject="coldbox:setting:version@cbInertia"; - - function configure() { - variables.defaultViewArgs = { "view": "main/index", "module": "cbInertia" }; - } + property name="defaultViewArgs" inject="coldbox:setting:defaultViewArgs@cbInertia"; function preProcess( event ) { if ( event.getHTTPHeader( "X-Inertia", "" ) == "" ) {