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 7542949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T08:18:06+00:00 2026-05-30T08:18:06+00:00

currently i have the new item form for my application. i used mustacheJS for

  • 0

currently i have the “new item form” for my application. i used mustacheJS for it’s template. there are some fields which need data from a database, sent via ajax. like for example, a certain select box.

<select name="customerOrder">
    {{#order}} <option value="{{id}}">{{itemName}}</option> {{/order}}
</select>

the data to fill this up with items would look like this:

{
    "order": [
        {
            "id":1,
            "itemName":"Meat Lover's Pizza"
        }, //and so on...
    ]
}

works fine until i am about to create the edit form, where, besides the form data to fill the select boxes and check boxes, i now have to mark the form elements as selected. however…

the item data is retrieved on another ajax call, hence another JSON object. i can’t necessarily merge because data might be of different structures. i could have tried this approach but this meant that form data and item data would be “one” – i don’t want that. i want a clear separation of the tangible data, and the non-tangible data

the item data looks like this basically, but may be nested somewhere in the JSON object:

{
    "customer":"mario",
    "order": 1          --> this item i want selected in the form
    //and so on...
}

if there was only some way to build the form, after that, populate and mark it seamlessly while still using mustache JS. i don’t want to hard code the data with their corresponding form fields.

i heard about runtime rendering and partials, but i can’t seem to see how i’d use them for this.

  • 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-05-30T08:18:07+00:00Added an answer on May 30, 2026 at 8:18 am

    I figured it out! I got the idea from using “inverted sections” in mustache.

    The one i did above seemed like a dead-end or if I pursued it, I’d be complicating everything.

    What I did was:

    1. Instead of having ajax send over the values for <option> and have a template for filling them in the <select>, i had my template built on the server side and fill the <select>‘s options with the data. Additionally, i used the template as “markers” for selected item.

    2. The only thing to fetch via ajax will be the the item data. I altered the structure of the JSON object to fit with the built template. Instead of handing over data, I instead, handed over “markers”

    The end result:

    //build from the server-side ready with options, and with "markers
    
    <select name="customerOrder">
        <option value="1" {{#order}}{{#i1}}selected="selected"{{/i1}}{{/order}}>Meat Lover's Pizza</option>
        <option value="2" {{#order}}{{#i2}}selected="selected"{{/i2}}{{/order}}>Supreme</option>
    </select>
    
    //JSON "edit-mode" data
    
    {
        "order": {
            "i2":true // this will render the "selected" attribute on the one with "i2"
        }             // refer to "non-empty" list and "inverted sections"
    }                 // http://mustache.github.com/mustache.5.html
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Simple question, I'm currently using Core Data. I have a form which is responsible
I currently have this useful code that I found elsewhere on StackOverflow: form.DrawToBitmap(bmp, new
I'm new to SharePoint and have a general question regarding list comparison. Currently, there
ASP.Net MVC 3 using C# I currently have a form with some dropdown lists
I currently have a simple menu_alter hook in a new module I'm building which
I currently have a _layout.cshtml used by every page of my website. I need
I currently have a windows form application composed of a textbox and two buttons
I currently have a variable that looks like this: val someVal = new HashMap[Float,
I am new to Rails routing and I currently have a problem and hope
Using dotnet 2.0. I currently have code like this : DataView dv = new

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.