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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:33:44+00:00 2026-06-16T09:33:44+00:00

I’m building an App using Meteor and am a little unclear how all the

  • 0

I’m building an App using Meteor and am a little unclear how all the code fits together using jQuery Mobile.

Basically I have an edit button in the header and when clicked I would like the content in the content section to change, and the edit button should change to say save. Clicking the save button should update the content and put the button back to it’s original state.

Edit button looks like:

<a data-icon="plus" data-role="button" class="edit" >edit</a>

Here’s a fiddle with no JS/JQ: http://jsfiddle.net/AU2cB/3/

The idea is show input fields when the edit button is clicked, and show the updated user inputted text when the save is clicked. I obviously haven’t got to the server part of this so any advice on how to do that with Meteor would be a bonus (I have the facebook login working using {{> loginButtons }})

NB: I’m very new to all. of this. It’s a relatively simple app, so in the root directory I just have 1 html file and one javascript file with if (Meteor.is_client) & if (Meteor.is_server) statements in it.

  • 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-16T09:33:46+00:00Added an answer on June 16, 2026 at 9:33 am

    Let’s say your button is in a template:

    <body>
      {{> editButton}}
      {{> fields}}
    </body>
    
    <template name="editButton">
      <a data-icon="plus" data-role="button" class="edit" >edit</a>
    </template>
    

    To wire this up with Meteor, attach events to the template:

    Template.editButton.events({
      "click [data-role='button']": function(e) {
        if ($(e.target).text() == "edit")
          $(e.target).text("save");
        else
          $(e.target).text("edit");
      }
    });
    

    That will toggle the text of the button when you click it. So what about showing or hiding related fields? We can use Session:

    Template.editButton.events({
      "click [data-role='button']": function(e) {
        if ($(e.target.text() == "edit") {
          $(e.target).text("save");
          Session.set("editing", true);
        }
        else {
          $(e.target).text("edit");
          Session.set("editing", false);
        }
      }
    });
    

    Now you need to listen to the value of editing and use it to tell Meteor whether the related fields should be shown or not:

    <template name="fields">
      {{#if editing}}
        <input type="text" name="myField"/>
      {{/if}}
    </template>
    
    Template.fields.editing = function() {
      return Session.get("editing");
    }
    

    Now when you click the button, Meteor will update the value of the associated Session key, and because Session is reactive, it will rerun the Template.fields.editing function and rerender the fields template.

    To save the data the user inputs, you could also use Session. I’ll let you figure that part out yourself, it’s pretty similar to the code I wrote here. To save user information persistently, look into Meteor.user() and Collections.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a text area in my form which accepts all possible characters from
I have thousands of HTML files to process using Groovy/Java and I need to
I am using Paperclip to handle profile photo uploads in my app. They upload
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I am reading a book about Javascript and jQuery and using one of the

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.