Welcome Guest, Not a member yet? Register   Sign In
Funny Javascript Problem
#1

[eluser]ibnclaudius[/eluser]
I know this is not a javascript forum, but...

I have a javascript to submit a form, but every time it runs, executes two times more than the last.

For example.

First submit: run the .post() one time.
Second submit: run the .post() three times.
Third submit: run .post() five times.
...

What am doing wrong:

Code:
$("#new-update-submit").click(function (event)
  {
   event.preventDefault();

   $("#new-update-submit").addClass("disabled");
   $("#new-update-submit").attr("disabled", true);
   $("#new-update-small-loader").show();

   if ($("#new-update-type").val() == '1')
   {
    var path = "/form/create_school_update";
   }
   else if ($("#new-update-type").val() == '2')
   {
    var path = "/form/create_class_update";
   }

   $.post(siteUrl + path, {
    update: $(".new-update-textarea").val()
   }, function (data)
   {
    var dataSplit = data.split(":");

    if (dataSplit[0] == 'TRUE')
    {
     $(".stream-header").height(50);
     $(".new-update-textarea").height(20);
     $(".new-update-actions").hide();
     $(".new-update-textarea").blur();
     $(".new-update-textarea").addClass("placeholder");
     $("#new-update-small-loader").hide();
     $(".no-content").hide();
     $(".stream-content").prepend("<div id='" + dataSplit[1] + "' class='update'><a href='#'><img class='update-picture' src='" + baseUrl + "/assets/img/no-picture.gif' /></a><div class='update-content'><a id='" + userId + "' class='update-name' href='#'>" + userName + "</a><br />" + $(".new-update-textarea").val() + "<br /><abbr class='timeago' title='" + dataSplit['2'] + ":" + dataSplit['3'] + ":" + dataSplit['4'] + "'></abbr></div></div>");
     $(".new-update-textarea").val("Compartilhe com sua escola uma notícia, evento...");
     $(".update").first().css("border-bottom", "1px solid #B9B6B6");
    
     jQuery("abbr.timeago").timeago();
    
     return;
    }
   });
  });


Messages In This Thread
Funny Javascript Problem - by El Forum - 02-08-2012, 06:16 PM



Theme © iAndrew 2016 - Forum software by © MyBB