I got a problem...
I had to use active admin for create a custom page -_-.. So I can't interact with my controller from my view.
So I've create many checkbox like this in my view,
input type="checkbox" class="filter" autocomplete="off" name="lundi" value="0" checked>Lundi
I'd like to use them in the same view I want to know if the checkbox is checked or not. So if someone ad a tricks? I'm a new user of rails.
You can use jQuery to check if checkbox is checked or not and do some thing on that decision, send ajax call or something else.
if ($("[name='lundi']").is(":checked")){
console.log("Do Something.");
}
Let me know if you need further help.
Related
So I'm trying to have an "address" input field on one of my view page, and i want to use that "address" as one of my parameters in my API call.
I am not sure if I should create a whole new controller/model just for this one address field, and I am sure there are definitely better ways to do this.
The idea came from Postmates Website, where on the homepage you can enter your address and Postmates will give you a list of available delivery services. I am looking for something similar to this.
Thanks in advance.
Create a form who's method points to one of your controller actions and then use the data from the form in that action.
So:
<form action="route/that/handles/delivery/address" method="get">
<input name="address">
<input type="submit">
</form>
Then in your controller action:
def handle_address
params[:address] // do stuff with this
end
Why do you need just one field on the table?
I agree it might be better to just send and update the parameter you want to change by modifying the controller instead.
I have Three checkbox
<g:checkBox name="startAccountingStatus" value="Yes" />
<g:checkBox name="startAccountingStatus" value="No" />
<g:checkBox name="startAccountingStatus" value="NA" />
i want something like RadioGroup. Here now i can select all the checkBoxes. i dont want that..
I can check only one checkBox.
I can do it in jQuery which i dont want to ..
Is there any way of achieving it in Grails Gsp.
Why don't you go with HTML radio group, also present in Grails?
You can make radio items look like checkbxes.
If you want the check be made on the client browser and not checked at server side after submission the only way is via javascript (jquery, prototype or simple javascript it's little important)
Actually its not actually a problem, but I'm thinking and searching for it for a while.
When we use php and to setup some link we can use something like-
some link
in this way anyone can see what is going on by looking at the url. Is there any possible way to keep it hidden like the POST method of the form element?
I don't want user to modify and play around with my parameters and values. Lets guess I don't want to encrypt the values and parameters and I can't use form element as they should be pure links. And also what if I don't want to use url rewriting engine.
Any ideas from the experts?
edit:
I forgot to mention another most important thing that I need to get the parameters and the values I want to pass through that link and do some stuffs in the page i'm linking to.
thanks again.
You can use a hidden form
<form action="realurl" method="post">
<input type="hidden" name="parameter" value="value1"></input>
</form>
<a onclick="forms[0].submit();" href="http://fake">link text</a>
I have a very simple object that needed an approved checkbox and a Declined checkbox
How can I check to make sure that both aren't checked?
A user should only check one, not both.
As #Christopher Marshall pointed out - this functionality is accomplished by the radio button type. Just change type="checkbox" to type="radio" and make sure the name is the same
Is there any possibility of having a button which will execute and action in a controller without a form ?. Also, i would like do do something like this, but i see that's not possible:
<g:form action="addFavourite">
<td>
<g:submitButton name="${it.area.name}" value="Add" class="button small blue"/><br><br>
</td>
</g:form>
To name the button with a value that comes from a controller isnt working. Any possible alternative for that? It gives me a null-error-code. And i'm 100% sure the value isnt null..
You can create a button outside a form that executes a controller action when it's clicked using the remoteFunction tag
<button type="button" name="myButton"
onclick="${remoteFunction(action:'bookByName', controller: 'book'
params:'\'bookName=\' + this.value')}">Click Here</button>
It kind of depends. If you want a button to submit to a server via a standard POST then no. HTML doesn't even have a button that works without a form. You can fake this with an image link that looks like a button, but really it just submits via a standard anchor tag. And this would perform a GET, not a POST.
However, if you want to use ajax, you could skip the Grails tags (as I often do) and use the HTML BUTTON element. Could even use the remoteFunction to make the ajax call if you want.
UPDATE: Doh! 2 of the same answers. :)
What does "it" stands here for? I think that is the culprit..
<g:submitButton name="${it.area.name}" value="Add" class="button small blue"/>