Experience the power of Parasails.js combined with either Vue Router or virtualPages

I came across Parasails.js documentation which mentions support for router and virtualPages, but lacks specifics on how to utilize these options.

I am familiar with the traditional Vue setup of importing Vue, VueRouter, and individual components directly into the .vue file.

However, when working with parasails.js, it seems like these parameters require undefined objects as they are not fully explained in the documentation. This leaves me guessing about their implementation.

This is what I have managed so far:

parasails.registerComponent('mainSearch', {      
  props: [
    'prop1',
    'prop2',
  ],

  html5HistoryMode: 'history',
  virtualPages: [
    { path: '/foo', component: 'page2' },
  ],

  template: `
    <div class="test">
       <p>Test</p>
       <router-link to="/foo">Foo</router-link>
       <router-view />
    </div>
  `,

  beforeMount: function() {
    //…
    // Attach any initial data from the server.
    _.extend(this, SAILS_LOCALS);

  },
  mounted: async function(){
    //…
  },
  beforeDestroy: function() {
    //…
  },
});

However, I encountered an error:

TypeError: In the HTML template (during render): Cannot read property 'matched' of undefined

Has anyone successfully used router or virtualPages in parasails.js and can provide guidance?

My next question pertains to passing components to virtualPages. Do I simply specify the name of another parasails registered component as a string? Or do I need to include that component in the code and pass it as an object similar to VueRouter?

Thank you for any assistance!

EDIT It seems that utilizing virtualPages on a parasails component does not work as intended.

Instead, adding these properties to a parasails page appears to be the correct approach:

  virtualPages: true,
  html5HistoryMode: 'history',
  virtualPageSlug: undefined,
  virtualPagesRegExp: /^\/test\/?([^\/]+)?/,

Although the previous error has been resolved, the

<router-view></router-view>
element is still not updating correctly when clicking on
<router-link to="/test/foo/">Foo</router-link>
.

A route was added to the project:

  '/test/foo/' : {
    view: 'pages/test'
  },

Any insights on why my router-view is not updating properly?

The documentation definitely needs some updates as it currently feels like a guessing game at every stage.

Answer №1

After reviewing the link you shared, it appears that there is some missing information on how to configure virtual pages. While I am not very familiar with using just parasails, I can provide insight into setting up virtual pages in Sails v1. I commonly use virtual pages for creating linkable modals.

To set up virtual pages, you need to define your data in the page script as follows:

virtualPages: true,
html5HistoryMode: 'history',
virtualPageSlug: undefined,
virtualPagesRegExp: /^\/foo\/bar\/?([^\/]+)?/,

In your ejs file, you can include the following code within a wrapping div:

v-if="virtualPageSlug === 'new'"

Update your Routes file with the following line:

'GET /foo/bar/:virtualPageSlug?': { action: 'foo/view-bar' },

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the reason for instanceof Map returning false?

Utilizing the Draft.js plugin called Mention. When accessing editorState.content.entityMap.mention, I am able to retrieve the value by: mention.get('address') However, when I attempt to verify if it is a Map using: console.log('mention&a ...

How can you establish a specific limit for digits between two numbers using vee-validate?

I'm looking to limit the number of digits a user can input to between 3 and 6. For some reason, I haven't been able to figure out how to do that. This is the code I currently have in place to require the user to input only three digits: <in ...

Loading a Vue.js template dynamically post fetching data from Firebase storage

Currently, I am facing an issue with retrieving links for PDFs from my Firebase storage and binding them to specific lists. The problem arises because the template is loaded before the links are fetched, resulting in the href attribute of the list remainin ...

Can the AJAX response be utilized for FullCalendar events?

I currently have the following code snippet in my event dropdown: $.ajax({ type: "POST", url: "CalendarServices.aspx/UpdateDrop", data: 'id=' + event.realid + '&start=' + $.fullCalendar.formatDate(event.start, 'yyy ...

Solving the "page not found" issue in NuxtJS: A guide to fixing errors during programmatic redirects

I am currently in the process of converting a Vue project into Nuxt. I have successfully implemented a navigation guard in the app using router.beforeEach(). Upon accessing the base URL localhost:3000, I encounter the image below: https://i.sstatic.net/ ...

Preserve the status of expanded nodes within the jqGrid tree grid

How can I make sure the Expanded State of my JQTree Grid is persistent? I want it to retain its previous expanded state even after reloading the grid. Can anyone guide me on how to achieve this? Thank you in advance! ...

How can you check the status of a message sent using Stompjs?

I have been working on a chat application using Spring Boot Websocket, STOMP, and stompjs. Below is a snippet of my JavaScript code: <script src="https://cdnjs.cloudflare.com/ajax/libs/sockjs-client/1.1.4/sockjs.min.js"></script> < ...

Use leaflet.js in next js to conceal the remainder of the map surrounding the country

I'm currently facing an issue and would appreciate some assistance. My objective is to display only the map of Cameroon while hiding the other maps. I am utilizing Leaflet in conjunction with Next.js to showcase the map. I came across a helpful page R ...

Is it possible to utilize a Next.js image for triggering a form submission via onClick for Google OAuth?

Disclaimer: Novice User I have successfully created a custom signin page with email and social media authentication using Next.js. Now I would like to customize the styling by incorporating Next.js/Image to replace the submit button with a clickable icon ...

Troubleshooting problem with Bootstrap Accordion & Silverstripe caused by Button class toggle bug

For a Silverstripe project, I am utilizing Bootstrap's accordion feature. The markup closely resembles Bootstrap's documentation but with slight modifications: aria-expanded="false" and panel-collapsed lack the in class to keep all items closed b ...

The type of undefined cannot be assigned to the specified type

I am currently working on implementing a pie chart (donut series) in Angular. Below are my HTML, CSS, and TypeScript files. I am following this tutorial resource: Link to CodeSandBox - https://codesandbox.io/s/apx-donut-simple-8fnji?from-embed import ...

The value of .val() is a combination of various values

I am currently working on a code that involves showing/hiding elements based on the selection of a value in a <select> tag. My next task is to modify it so that the class is added if .val() is equal to not only '16' but also '14' ...

Error: dispatch function does not exist - TypeMismatch

Recently, I started working with react-redux and incorporated the react-thunk middleware into my project. However, I encountered an issue where I kept receiving the error "Uncaught TypeError: dispatch is not a function" whenever I attempted to execute my a ...

Utilize JavaScript API for generating and retrieving XSD schema and XML documents

Are there any stable JavaScript APIs that can be used to generate and read XSD schemas and XML documents? My specific requirement is: Allow one user to define/generate an XSD schema through a UI. Later, allow another user to provide appropriate data ...

Trying to filter out repetitive options in an autocomplete box

Using the jQuery autocomplete plugin, I am trying to display 5 unique search results. Initially, I achieved this by limiting the stored procedure to return only 5 results, but now I want to remove duplicates while still showing 5 distinct results. I'm ...

NextJS build problem causing all content to become static

As a newcomer to NextJS with prior experience in basic React apps, I recently attempted to deploy a CRUD NextJS app (utilizing prisma and mongoDB). Everything runs smoothly with npm run dev, but issues arise when transitioning to npm run build followed by ...

In Angular, the exclusion of a name attribute in a textarea element does not automatically generate an instance

I came across this jade template for creating a modal dialog in Angular Material. Unfortunately, I couldn't convert it to HTML because the jade site was not working. md-dialog(aria-label='Reject', ng-cloak='') form(name="rejecti ...

Exploring How to Identify and Eliminate Duplicate Objects in 2 Arrays

I'm working with two arrays of objects in JavaScript and my goal is to compare, merge the contents, and sort by id. Specifically, I want the final sorted array to include all objects from the first array, as well as any objects from the second array t ...

Track your status with jQuery technology

I have a link: <a href="/test/number/3/phone/0">33df</a> Is there a way to determine if the words 'number' and 'phone' are present in this link? I am looking for a function similar to: check('number', ' ...

Using Jquery to retrieve slider values through an iterative .each loop

I am facing an issue with my dynamic sliders that need to be looped through. Here is the link to my jsFiddle for reference: http://jsfiddle.net/mtait/R5czJ/ The HTML code snippet looks like this: <label for="slider1">item 1</label> & ...