(Rails) Form method for To Do List quick edit





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I'm trying to do a quick edit feature in my To Do List: if the user clicks on anywhere in the red box shown (in Edit 2), he'll be redirected to the edit action in the controller.



However, which form methods should I use? The only one that worked so far was link_to: I simply added the link to the title. But it doesn't span the entire red box. Thank you in advance!



EDIT



Partial task that represents 1. checkbox 2. title and 3. actions (show, edit, tags)



<% status = get_status(task) %>
<section id=<%=task.id%> class=<%=status%>>
<!-- checkbox -->
<%= form_with scope: task, url: completed_task_path(task), method: :patch do |form|%>
<%= form.check_box :completed%>
<!-- Title: I want make this a box -->
<%= task.title %>

<!-- Labels -->
<section class="actions">
<%= render partial: 'actions', locals: {task: task} %>
</section>
<!-- Details -->
<section class= "details">
<%= task.details %>
</section>
<% end %>
</section>


Edit 2

Here's how it looks like currently.



TODO










share|improve this question

























  • Paste the html code from the view file.

    – Emu
    Jan 3 at 4:19











  • Done, thank u for ur time!

    – Larry Law
    Jan 3 at 4:33











  • You can wrap the whole task partial into a <%= link_to do <% end %> block.

    – Emu
    Jan 3 at 4:50











  • do you want some features like edit on the same place or you want to redirect to particular page

    – Cryptex Technologies
    Jan 3 at 5:04











  • @Emu Doing so makes the actions links to the edit action; they are themselves links to other actions. I'd like only the red box to link to the edit action. I've uploaded in edit 2 how it looks like currently. Thank u for ur time!

    – Larry Law
    Jan 3 at 5:40




















1















I'm trying to do a quick edit feature in my To Do List: if the user clicks on anywhere in the red box shown (in Edit 2), he'll be redirected to the edit action in the controller.



However, which form methods should I use? The only one that worked so far was link_to: I simply added the link to the title. But it doesn't span the entire red box. Thank you in advance!



EDIT



Partial task that represents 1. checkbox 2. title and 3. actions (show, edit, tags)



<% status = get_status(task) %>
<section id=<%=task.id%> class=<%=status%>>
<!-- checkbox -->
<%= form_with scope: task, url: completed_task_path(task), method: :patch do |form|%>
<%= form.check_box :completed%>
<!-- Title: I want make this a box -->
<%= task.title %>

<!-- Labels -->
<section class="actions">
<%= render partial: 'actions', locals: {task: task} %>
</section>
<!-- Details -->
<section class= "details">
<%= task.details %>
</section>
<% end %>
</section>


Edit 2

Here's how it looks like currently.



TODO










share|improve this question

























  • Paste the html code from the view file.

    – Emu
    Jan 3 at 4:19











  • Done, thank u for ur time!

    – Larry Law
    Jan 3 at 4:33











  • You can wrap the whole task partial into a <%= link_to do <% end %> block.

    – Emu
    Jan 3 at 4:50











  • do you want some features like edit on the same place or you want to redirect to particular page

    – Cryptex Technologies
    Jan 3 at 5:04











  • @Emu Doing so makes the actions links to the edit action; they are themselves links to other actions. I'd like only the red box to link to the edit action. I've uploaded in edit 2 how it looks like currently. Thank u for ur time!

    – Larry Law
    Jan 3 at 5:40
















1












1








1








I'm trying to do a quick edit feature in my To Do List: if the user clicks on anywhere in the red box shown (in Edit 2), he'll be redirected to the edit action in the controller.



However, which form methods should I use? The only one that worked so far was link_to: I simply added the link to the title. But it doesn't span the entire red box. Thank you in advance!



EDIT



Partial task that represents 1. checkbox 2. title and 3. actions (show, edit, tags)



<% status = get_status(task) %>
<section id=<%=task.id%> class=<%=status%>>
<!-- checkbox -->
<%= form_with scope: task, url: completed_task_path(task), method: :patch do |form|%>
<%= form.check_box :completed%>
<!-- Title: I want make this a box -->
<%= task.title %>

<!-- Labels -->
<section class="actions">
<%= render partial: 'actions', locals: {task: task} %>
</section>
<!-- Details -->
<section class= "details">
<%= task.details %>
</section>
<% end %>
</section>


Edit 2

Here's how it looks like currently.



TODO










share|improve this question
















I'm trying to do a quick edit feature in my To Do List: if the user clicks on anywhere in the red box shown (in Edit 2), he'll be redirected to the edit action in the controller.



However, which form methods should I use? The only one that worked so far was link_to: I simply added the link to the title. But it doesn't span the entire red box. Thank you in advance!



EDIT



Partial task that represents 1. checkbox 2. title and 3. actions (show, edit, tags)



<% status = get_status(task) %>
<section id=<%=task.id%> class=<%=status%>>
<!-- checkbox -->
<%= form_with scope: task, url: completed_task_path(task), method: :patch do |form|%>
<%= form.check_box :completed%>
<!-- Title: I want make this a box -->
<%= task.title %>

<!-- Labels -->
<section class="actions">
<%= render partial: 'actions', locals: {task: task} %>
</section>
<!-- Details -->
<section class= "details">
<%= task.details %>
</section>
<% end %>
</section>


Edit 2

Here's how it looks like currently.



TODO







ruby-on-rails






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Jan 3 at 5:43







Larry Law

















asked Jan 3 at 4:06









Larry LawLarry Law

2015




2015













  • Paste the html code from the view file.

    – Emu
    Jan 3 at 4:19











  • Done, thank u for ur time!

    – Larry Law
    Jan 3 at 4:33











  • You can wrap the whole task partial into a <%= link_to do <% end %> block.

    – Emu
    Jan 3 at 4:50











  • do you want some features like edit on the same place or you want to redirect to particular page

    – Cryptex Technologies
    Jan 3 at 5:04











  • @Emu Doing so makes the actions links to the edit action; they are themselves links to other actions. I'd like only the red box to link to the edit action. I've uploaded in edit 2 how it looks like currently. Thank u for ur time!

    – Larry Law
    Jan 3 at 5:40





















  • Paste the html code from the view file.

    – Emu
    Jan 3 at 4:19











  • Done, thank u for ur time!

    – Larry Law
    Jan 3 at 4:33











  • You can wrap the whole task partial into a <%= link_to do <% end %> block.

    – Emu
    Jan 3 at 4:50











  • do you want some features like edit on the same place or you want to redirect to particular page

    – Cryptex Technologies
    Jan 3 at 5:04











  • @Emu Doing so makes the actions links to the edit action; they are themselves links to other actions. I'd like only the red box to link to the edit action. I've uploaded in edit 2 how it looks like currently. Thank u for ur time!

    – Larry Law
    Jan 3 at 5:40



















Paste the html code from the view file.

– Emu
Jan 3 at 4:19





Paste the html code from the view file.

– Emu
Jan 3 at 4:19













Done, thank u for ur time!

– Larry Law
Jan 3 at 4:33





Done, thank u for ur time!

– Larry Law
Jan 3 at 4:33













You can wrap the whole task partial into a <%= link_to do <% end %> block.

– Emu
Jan 3 at 4:50





You can wrap the whole task partial into a <%= link_to do <% end %> block.

– Emu
Jan 3 at 4:50













do you want some features like edit on the same place or you want to redirect to particular page

– Cryptex Technologies
Jan 3 at 5:04





do you want some features like edit on the same place or you want to redirect to particular page

– Cryptex Technologies
Jan 3 at 5:04













@Emu Doing so makes the actions links to the edit action; they are themselves links to other actions. I'd like only the red box to link to the edit action. I've uploaded in edit 2 how it looks like currently. Thank u for ur time!

– Larry Law
Jan 3 at 5:40







@Emu Doing so makes the actions links to the edit action; they are themselves links to other actions. I'd like only the red box to link to the edit action. I've uploaded in edit 2 how it looks like currently. Thank u for ur time!

– Larry Law
Jan 3 at 5:40














1 Answer
1






active

oldest

votes


















0














One way to do it is via javascript (and a little bit of rails). You did not upload the html for the partial, but I assume it has a div wrapping the checkbox and the label. You could add something like:



<div onClick="window.location.href = '#{your_controller_action_path}'"></div>


Where "your_controller_action_path" is the helper method for the url where you want to redirect.






share|improve this answer



















  • 1





    Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

    – Larry Law
    Jan 4 at 5:25














Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016219%2frails-form-method-for-to-do-list-quick-edit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









0














One way to do it is via javascript (and a little bit of rails). You did not upload the html for the partial, but I assume it has a div wrapping the checkbox and the label. You could add something like:



<div onClick="window.location.href = '#{your_controller_action_path}'"></div>


Where "your_controller_action_path" is the helper method for the url where you want to redirect.






share|improve this answer



















  • 1





    Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

    – Larry Law
    Jan 4 at 5:25


















0














One way to do it is via javascript (and a little bit of rails). You did not upload the html for the partial, but I assume it has a div wrapping the checkbox and the label. You could add something like:



<div onClick="window.location.href = '#{your_controller_action_path}'"></div>


Where "your_controller_action_path" is the helper method for the url where you want to redirect.






share|improve this answer



















  • 1





    Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

    – Larry Law
    Jan 4 at 5:25
















0












0








0







One way to do it is via javascript (and a little bit of rails). You did not upload the html for the partial, but I assume it has a div wrapping the checkbox and the label. You could add something like:



<div onClick="window.location.href = '#{your_controller_action_path}'"></div>


Where "your_controller_action_path" is the helper method for the url where you want to redirect.






share|improve this answer













One way to do it is via javascript (and a little bit of rails). You did not upload the html for the partial, but I assume it has a div wrapping the checkbox and the label. You could add something like:



<div onClick="window.location.href = '#{your_controller_action_path}'"></div>


Where "your_controller_action_path" is the helper method for the url where you want to redirect.







share|improve this answer












share|improve this answer



share|improve this answer










answered Jan 3 at 17:38









Rodrigo EcheconeaRodrigo Echeconea

963




963








  • 1





    Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

    – Larry Law
    Jan 4 at 5:25
















  • 1





    Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

    – Larry Law
    Jan 4 at 5:25










1




1





Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

– Larry Law
Jan 4 at 5:25







Update for future ref: 1. Issue with div is that it is a block, thus it indents a new line. To circumvent this, I had to make it a flex box that is 1) no wrap 2) horizontal direction 3) justify content center. 2. Issue with passing in the link is that it becomes a HTML instead of an JS request. To circumvent this, I had to pass in a javascript function into on click which takes in my_controller_action_path, and define an ajax get request on this string. Thank you for pointing me in the right direction @Rodrigo Echeconea!

– Larry Law
Jan 4 at 5:25






















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54016219%2frails-form-method-for-to-do-list-quick-edit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

Does disintegrating a polymorphed enemy still kill it after the 2018 errata?

A Topological Invariant for $pi_3(U(n))$