Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8703231
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:49:56+00:00 2026-06-13T02:49:56+00:00

Hope someone can help me as I’ve been searching for hours. I’m planning on

  • 0

Hope someone can help me as I’ve been searching for hours.

I’m planning on using jeditable for in place editing with ruby on rails. I can do normal text just fine but I’m having some problems with the select option.
I’d like to pass the data to the editable field through a collection embedded in the field using data-attributes. Since I have around 40 or 50 fields on my page I can’t just create one call per each editable field.

Here’s some code:

$(".editable[data-type='select']").editable("/post/here", {
    id: '_action',
    height: '1.8em',
    type: "select",
    data: $(this).data("collection")
    submit: "Ok",
    submitdata : function () {
        return {
            "id": this.getAttribute("data-query"),
            "index": this.getAttribute("data-index")                
        };
    }
});

The collection can be found on the link which I generate through a helper method:

content_tag(:div, opt_value, class: "editable", id: options[:_action], "data-query" => query.id, "data-index" => options[:index], "data-type" => "select", "data-collection" => Hash[double_array].to_json, style: "display:inline")

which produces something like this:

<div class="editable" data-collection="{'0':'Option 0','1':'Option 1'}" data-query="33" data-type="select" id="some_action" style="display:inline">Option 1</div>

Obviously this doesn’t work:

data: $(this).data("collection")

By trying to stay as unobtrusively as possible, is there a way to access the embedded attributes within the calling editable field?

Thanks,
Octavian

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T02:49:57+00:00Added an answer on June 13, 2026 at 2:49 am

    Apparently that’s a bit difficult to perform.

    I ended up editing the src in a way that if a tag has a data-collection attribute it will try to use that data, otherwise it will perform as before.

    Here’s some code:
    Original

    ...truncated...
    
    content : function(data, settings, original) {
      /* If it is string assume it is json. */
      if (String == data.constructor) {
        eval ('var json = ' + data);
      } else {
        /* Otherwise assume it is a hash already. */
        var json = data;
      }
    
    ...truncated...
    

    Edited code:

    ...truncated...
    
    content : function(data, settings, original) {
      /* If it is string assume it is json. */
      if (collection = $(original).data("collection")) {
        var json = collection;
      } else if (String == data.constructor) {
        eval ('var json = ' + data);
      } else {
        /* Otherwise assume it is a hash already. */
        var json = data;
      }
    
    ...truncated...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hope someone can help me - I've been using the Hello World Guide to
I hope someone can help, I've been trawling SO for hours and can't find
hope someone can help me on this as been stuck for hours. I am
I hope someone can help... This issue has been discussed here and I have
Hope someone can help with this. I've been up and down the web and
hope someone can help with this problem that's been driving me insane for ages.
I hope someone can help with this issue. I have a popup iframe using
I hope someone can help me. This has been driving me crazy for days.
hope someone can help because I've been racking my brains for the best part
Hope someone can help with this as it's driving me mad! I'm using Aptana

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.