CBWIRE
InstallSource CodeIssuesSupport
v2.x
v2.x
  • Introduction
  • Release History
    • What's New With 2.2
    • What's New With 2.1
    • What's New With 2.0
  • Getting Started
  • Examples
  • Essentials
    • Configuration
    • Wires
    • Data Properties
    • Computed Properties
      • Computed Properties ( Proxied )
    • Actions
    • Templates
    • Events & Listeners
    • Wire Lifecycle
    • JavaScript
    • Testing
  • Wire Features
    • Validation
    • File Uploads
    • Query String
    • Redirecting
    • Dependency Injection
  • Template Features
    • Directives
    • Loading States
    • Polling
    • Prefetching
    • Offline State
    • Defer Loading
    • Dirty State
  • Integrations
    • ContentBox CMS
    • Turbo
    • AlpineJS
    • Inline Scripts
Powered by GitBook
On this page

Was this helpful?

Export as PDF
  1. Wire Features

Query String

PreviousFile UploadsNextRedirecting

Last updated 2 years ago

Was this helpful?

It can be useful at times to update the browser's query string when your state changes.

Example

Let's say you are building a to search articles, and want the query string to reflect the current search value like so:

https://yourapp.com/search-articles?search=some+string

This way, when a user hits the back button or bookmarks the page, you can get the initial state out of the query string rather than resetting the every time.

You can add a queryString variable to your and CBWIRE will update the query string every time the property value changes and also update the property when the query string changes.

component extends="cbwire.models.Component" {

    data = {
        "search": ""
    };
    
    queryString = [ "search" ];
}
<div>
    <input wire:model="search" type="search" placeholder="Search articles...">
</div>
Wire's
Wire
Wire
Wires