Sails: Cloud SDK - add param to url through Javascript?

Created on 19 Jan 2018  Â·  6Comments  Â·  Source: balderdashy/sails

Sails version: 1.0.0-45
Node version: 6.9.0
NPM version: 3.10.3
DB adapter name: N/A
DB adapter version: N/A
Operating system: Ubuntu 16.04

Before you submit an issue for Sails, please make sure you have read the issue contribution guide (http://bit.ly/sails-issue-guide) carefully, and then verify the following by typing an X in between each set of [ ] brackets below (don't make any other changes to the text!):

  • [x] I am experiencing a concrete technical issue (aka a bug) with Sails (ideas and feature proposals should follow the guide for proposing features and enhancements (http://bit.ly/sails-feature-guide), which involves making a pull request). If you're not 100% certain whether it's a bug or not, that's okay--you may continue. The worst that can happen is that the issue will be closed and we'll point you in the right direction.

  • [x] I am not asking a question about how to use Sails or about whether or not Sails has a certain feature (please refer to the documentation(http://sailsjs.com), or post on http://stackoverflow.com, our Google Group (http://bit.ly/sails-google-group) or our live chat (https://gitter.im/balderdashy/sails).

  • [x] I have already searched for related issues, and found none open (if you found a related _closed_ issue, please link to it in your post).

  • [x] My issue title is concise, on-topic and polite ("jst.js being removed from layout.ejs on lift" is good; "templates dont work" or "why is sails dumb" are not so good).

  • [x] I have tried all the following (if relevant) and my issue remains:

    • Make sure you have the right app lifted.
    • Make sure you've killed the Sails server with CTRL+C and started it again.
    • Make sure you closed any open browser tabs pointed at localhost before starting Sails.
    • Make sure you do not have any other Sails apps running in other terminal windows.
    • Make sure the app you are using to reproduce the issue has a clean node_modules/ directory, meaning:
    • no dependencies are linked (e.g. you haven't run npm link foo)
    • that you haven't made any inline changes to files in the node_modules/ folder
    • that you don't have any weird global dependency loops. The easiest way to double-check any of the above, if you aren't sure, is to run: rm -rf node_modules && npm cache clear && npm install.

and finally...

  • [x] I can provide steps to reproduce this issue that others can follow.

Ideally, this involves creating a new repo that demonstrates the problem (see instructions at http://bit.ly/sails-issue-repro). Even though your issue may seem so simple to reproduce that a new repo is unnecessary, you'd be surprised how many solutions present themselves when you start from sails new and attempt to recreate your issue from scratch in a new app. This ensures that the real issue isn't in your user code (a forgotten policy file, perhaps?) or in a third-party module. If you're absolutely _convinced_ that a new repo is unnecessary, provide clear, concise and _specific_ steps to reproduce the problem in your post (not "create a model then do blueprint create").

OKAY--THANKS FOR READING!


Hello I use the v1.0.0-45 of Sails.

I load with cloud SDK my URL

I want to know how pass ":id" with "ajax-form" component ?

This is the URL generated :

"updateArticle":{"verb":"PUT","url":"/api/v1/articles/:id","args":["title","content","uploadFile"]}}

My header to call "ajaxForm" component looks like this :

    <ajax-form action="updateArticle" :syncing.sync="syncing" :cloud-error.sync="cloudError" @submitted="submittedForm()" :handle-parsing="handleParsingForm" enctype="multipart/form-data">

How can I happen the ":id" to it ? I try in action with "updateArticle(<%= id %>)" but not work ?

question

All 6 comments

How can I happen the ":id" to it ? I try in action with "updateArticle(<%= id %>)" but not work ?

Hey @chadyred, in your JavaScript, when you're parsing data for the form, you'll want to set id. For example:

• HTML: https://github.com/mikermcneil/ration/blob/a3c9709cd9bd7c174b6db8ca25024cfc70da9219/views/pages/things/available-things.ejs#L138-L149
• JavaScript: https://github.com/mikermcneil/ration/blob/1d85f20f7f8c3c5d9c2f524172ffcc9c47700fcb/assets/js/pages/things/available-things.page.js#L270-L274

That's from the app we built for the new Platzi course -- goes online March 1 (in the mean time feel free to check out the repo and/or play with it at https://ration.io)

So the :handle-parsing allow us to retrieve the data of form through JavaScript like here the id which you use for the delete ?

So if i fille in field notre on field list but on URL, like the id, it Will be fill?

@chadyred,@mikermcneil: Hello, I'm a repo bot-- nice to meet you!

It has been 30 days since there have been any updates or new comments on this page. If this issue has been resolved, feel free to disregard the rest of this message and simply close the issue if possible. On the other hand, if you are still waiting on a patch, please post a comment to keep the thread alive (with any new information you can provide).

If no further activity occurs on this thread within the next 3 days, the issue will automatically be closed.

Thanks so much for your help!

@chadyred That's right-- the SDK will do its best to plug in the data you feed it.

You can either use the bundled <ajax-form> component, or write your own form-processing front-end code and have it call Cloud.updateArticle(…).

Based on what I'm seeing here, it looks like the issue is that your controller action does not have an id input. (I can tell because of the args in your generated cloud.setup.js file.) To resolve this, add the input, then run sails run rebuild-cloud-sdk.

Sorry for the delay.

All works great : this.id is set on JS and automaticaly it's send for id input filed, the one I miss.

So I have remove my hidden field.

Thanks for your awesome work.

Was this page helpful?
0 / 5 - 0 ratings