Skip to content

Commit

Permalink
Merge pull request #8 from theblindfrog/feature/make-root-element-id-…
Browse files Browse the repository at this point in the history
…customizable

feat: Make root element id customizable
  • Loading branch information
tbreuss authored Jul 24, 2024
2 parents bad79fd + b2b4e64 commit 1e93f4d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions Inertia.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ class Inertia extends Component

/** @var string */
public $view = '@tebe/inertia/views/inertia';

/** @var string */
public $rootElementId = 'app';

/**
* @inheritDoc
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ return [
'components' => [
'inertia' => [
'class' => 'tebe\inertia\Inertia'
'rootElementId' => 'app' // optional per https://inertiajs.com/client-side-setup#defining-a-root-element
],
'request' => [
'cookieValidationKey' => '<cookie_validation_key>',
Expand Down
2 changes: 1 addition & 1 deletion views/inertia.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
/* @var $page array */
?>
<div id="app" data-page="<?= htmlspecialchars(json_encode($page)) ?>"></div>
<div id="<?= \Yii::$app->get('inertia')->rootElementId ?>" data-page="<?= htmlspecialchars(json_encode($page)) ?>"></div>

0 comments on commit 1e93f4d

Please sign in to comment.