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

  • Home
  • SEARCH
  • 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 6644763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:12:18+00:00 2026-05-26T00:12:18+00:00

I am creating dynamic controls using jQuery by reading the query string parameter. These

  • 0

I am creating dynamic controls using jQuery by reading the query string parameter. These controls can be dragged to lay them in neat manner, after the drop event in drag/drop I would update the position and state of control through hidden field. It’s just that my implementation now updates data at each drop which is not nice. I also did this through event but did not work well

Current Implementation

/*Create controls when only query string exists*/
if (config.params) {
    //parse the query string json as a object
    //ex:{type:"textbox",x:100,y:200,label:Name}
    var params = $.parseJSON(config.params);

    //for each control in json add it to document body
    $(params).each(function (idx, obj) {
        var id = new Date();//for generating dynamic id
        id = id.getTime();
        $("<span>").addClass(obj.css).load(function (ev) {
            var a = this;
            $(a).data("keys", {
                key: $("label", a).text()**certainly label wont be found**,
                value: $("input[name]:hidden", a)
            });
        }).
        easydrag().ondrop(function (e, el) {
            //easydrag drag drop plugin
            var a = $(el),
                b = a.data("keys"),
                key = b.key,
                value = b.value;
            value.val(key + "$" + e.pageX + "$" + e.pageY);
        }).
        css({
            position: "absolute",
            top: obj.y,
            left: obj.x
        }).
        append($("<label>", {
            "for": id
        }).
         html(obj.label).
         append(config.ELEMENTS(obj.type).attr("id", id))).
         append($("<input>", {
            "type": "hidden",
            "name": "CONTROL$POSITION",
            "id": "control_position_" + idx
         })).
        appendTo("form");
    });
} 

Question

  1. As you see I attach data to span element on load. But since it is load event i won’t have the inner label and hidden fields. I need to set the data on elementspan only once, since during drop event i will access the label and hidden field to update the current position of the control. I don’t want to query the dom on each drop for the label and hidden field that’s my purpose.
  2. Also give me ideas on how I can redraw the controls after a postback?
  • 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-26T00:12:19+00:00Added an answer on May 26, 2026 at 12:12 am

    Get rid of load, and temporary store a reference to the element. Execute the code after the element has fully finished creating:

    var span = $("<span>");
    span.addClass(obj.css).
        easydrag(). //et cetera
        ....
        appendTo("form");
    
    //After the element has finished:
    $(span).data("keys", {
        key: $("label", span).text(),
        value: $("input[name]:hidden", span)
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When creating a class library in C++, you can choose between dynamic ( .dll
I am creating huge amounts of dynamic controls, and for everything that must have
I am using Ext.Net and I have a problem. I am creating dynamic buttons.
When creating dynamic ajax controls you may experience a pre-render issue on postbacks. You
which method do you prefer for creating dynamic sql queries? formating or streaming? Is
What choices do I have for creating stateful dynamic content in an ASP.Net web
So I was thinking about creating a dynamic sql question, meaning that i want
To the best of my knowledge, creating a dynamic Java proxy requires that one
We are creating dynamic text boxes and buttons inside a grid for each row.
I would like to create a dynamic proxy for binding WinForms controls to objects

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.