jQuery Plugins » through https://jqueryplugins.info jQuery plugins, tutorials and resources Fri, 21 Oct 2011 17:13:56 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 getJSON wont allow array to pass through https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/ https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/#comments Sun, 16 Oct 2011 08:13:32 +0000 Admin https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/ Post link: getJSON wont allow array to pass through

function near_home(lat,long,miles) { var url = "api_url"; var places = []; $ .getJSON(url, function(data) { $ .each(data['results'], function(i, place) { places.push(place); }); console.log(places); }); console.log(places); return places; } So the...

]]>
Post link: getJSON wont allow array to pass through

function near_home(lat,long,miles) {
  var url = "api_url";
  var places = [];

  $  .getJSON(url, function(data) {
    $  .each(data['results'], function(i, place) {
      places.push(place);
    });
    console.log(places);
  });
  console.log(places);
  return places;
}

So the first console.log() will return the desired objects. But the second console method results in null data. I’ve rewritten this thing a few times over and can’t seem to find reason for this madness. What am I missing?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/getjson-wont-allow-array-to-pass-through/feed/ 0
JQuery infinite loop through .each iteration with a pause between each iteration https://jqueryplugins.info/2011/10/jquery-infinite-loop-through-each-iteration-with-a-pause-between-each-iteration/ https://jqueryplugins.info/2011/10/jquery-infinite-loop-through-each-iteration-with-a-pause-between-each-iteration/#comments Fri, 07 Oct 2011 13:15:21 +0000 Admin https://jqueryplugins.info/2011/10/jquery-infinite-loop-through-each-iteration-with-a-pause-between-each-iteration/ Post link: JQuery infinite loop through .each iteration with a pause between each iteration

Basically I am looping through tweets. I want to pause for 20seconds between each tweet and after the last tweet I want to go back to tweet one and repeat...

]]>
Post link: JQuery infinite loop through .each iteration with a pause between each iteration

Basically I am looping through tweets. I want to pause for 20seconds between each tweet and after the last tweet I want to go back to tweet one and repeat the process infinitely.

Here is my code so far, I’ve tried tackling this problem by reading other peoples examples but cant quite seem to hit the nail on the head. I do keep running into the set timeout function too.

// DisplayTweets.
function displayTweets(tweets)
{
    // Checks if any tweets exist.
    if ($  .isArray(tweets) !== false)
    {
        // Show error message.
        $  ('p#tweet').text(tweets);
    }
    else
    {
        // Parse JSON into Javascript object.
        var objTweets = jQuery.parseJSON(tweets);

        // Loop through
        $  .each(objTweets, function(i, objTweet) {
            //alert(objTweet.tweet);
            $  ('p#tweet').text(objTweet.tweet);
        });
    }
}

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/jquery-infinite-loop-through-each-iteration-with-a-pause-between-each-iteration/feed/ 0
Speed improval through conditional function execution? https://jqueryplugins.info/2011/10/speed-improval-through-conditional-function-execution/ https://jqueryplugins.info/2011/10/speed-improval-through-conditional-function-execution/#comments Fri, 07 Oct 2011 04:13:36 +0000 Admin https://jqueryplugins.info/2011/10/speed-improval-through-conditional-function-execution/ Post link: Speed improval through conditional function execution?

I have a website with multiple pages, each of them with custom event handlers attached to certain elements. Each page has an id in the html markup (#page1, #page2, …)....

]]>
Post link: Speed improval through conditional function execution?

I have a website with multiple pages, each of them with custom event handlers attached to certain elements. Each page has an id in the html markup (#page1, #page2, …).

In my javascript file for the website I have seperated the functions for each site in self executing modules, simplified like so:

//module 1 for stuff that happens on #page1
(function() {
    // stuff to happen for a specific site (#page1 or #page2 or ...)
})();

I thought I could execute certain page related modules only if the #id is found in the current document like:

if( $  ("#page1").length ) {// call module 1}

… because a lot of event delegation happens in some modules.

Is this a common/good approach to speed up things? Or is it better to include the modules in seperated js files only on the subsites where they are needed? Or any other method/ideas?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/speed-improval-through-conditional-function-execution/feed/ 0
Do looping through items and adding handlers to it hurt performance https://jqueryplugins.info/2011/10/do-looping-through-items-and-adding-handlers-to-it-hurt-performance/ https://jqueryplugins.info/2011/10/do-looping-through-items-and-adding-handlers-to-it-hurt-performance/#comments Thu, 06 Oct 2011 16:15:35 +0000 Admin https://jqueryplugins.info/2011/10/do-looping-through-items-and-adding-handlers-to-it-hurt-performance/ Post link: Do looping through items and adding handlers to it hurt performance

Does it hurt in performance when I loop through list-items and add a clickhandler to all separate items? The reason I do this is because I would only like to...

]]>
Post link: Do looping through items and adding handlers to it hurt performance

Does it hurt in performance when I loop through list-items and add a clickhandler to all separate items?

The reason I do this is because I would only like to make the list item clickable if it contains an hyperlink.

The code I’m currenlty using is:

$  ('ul.paginator li').each(function() {
  if ($  ('a', this).length > 0) {
    $  (this).css('cursor', 'pointer');
    $  (this).click(function() {
      location.href = $  ('a', this).attr('href');
    });
  }
});

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/do-looping-through-items-and-adding-handlers-to-it-hurt-performance/feed/ 0
updating a cakephp model field through jquery https://jqueryplugins.info/2011/10/updating-a-cakephp-model-field-through-jquery/ https://jqueryplugins.info/2011/10/updating-a-cakephp-model-field-through-jquery/#comments Thu, 06 Oct 2011 00:18:16 +0000 Admin https://jqueryplugins.info/2011/10/updating-a-cakephp-model-field-through-jquery/ Post link: updating a cakephp model field through jquery

i’m trying to update a the field of a cakePHP model through a jquery request. eventhough the ajax call is a success , the model isn’t updated on the database...

]]>
Post link: updating a cakephp model field through jquery

i’m trying to update a the field of a cakePHP model through a jquery request.

eventhough the ajax call is a success , the model isn’t updated on the database .

<?php $  Url = Router::url(array('controller'=>'coupons','action'=>'update_statut'),true); ?>

  $  .post('<?php echo $  Url ?>', { id: id},function(data)
      { alert("sucess");
    }).error(function() { alert("error"); })
        .complete(function() { alert("complete"); });

on the controller’s side here’s the action :

function update_statut(){
      Configure::write('debug', 0);
      $  this->autoRender = false;
       if($  this->RequestHandler->isAjax()) {
            $  this->Coupon->id= $  this->params['form']['id'];
            $  this->Coupon->saveField('statut','terminé');
           }

i even hardcoded the id in the action to make sure it fits with my table row.

any suggestions

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/updating-a-cakephp-model-field-through-jquery/feed/ 0
extra spaces being added with on click function through insertBefore https://jqueryplugins.info/2011/09/extra-spaces-being-added-with-on-click-function-through-insertbefore/ https://jqueryplugins.info/2011/09/extra-spaces-being-added-with-on-click-function-through-insertbefore/#comments Sun, 25 Sep 2011 00:13:16 +0000 Admin https://jqueryplugins.info/2011/09/extra-spaces-being-added-with-on-click-function-through-insertbefore/ Post link: extra spaces being added with on click function through insertBefore

I have problem of too many spaces being added, seems like each click adds a space. With one click on the #main-edit area, it works correctly, one span for one...

]]>
Post link: extra spaces being added with on click function through insertBefore

I have problem of too many spaces being added, seems like each click adds a space. With one click on the #main-edit area, it works correctly, one span for one space bar keypress. With two, two spans are added on one space bar keypress, and etc.

Here is the code:

$  ("#main-edit").click( function() {
var cursorExists = $  ("#cursor").length;
if (!cursorExists){
   $  cursorStart.append("<input type='text' id = 'cursor' />");
   $  ("#cursor").markCursor();

}
   if (cursorExists){
    $  ("#cursor").markCursor();

}

});

jQuery.fn.markCursor = function(e){
    $  (this).focus();
   $  (this).keyup(function(e) {
  $  cursorStart.enterText(e);

});

};

jQuery.fn.enterText = function(e){
var $  cursor = $  ("#cursor");
if (e.keyCode == 32){
    $  cursor.val("");
    $  ("<span class = 'space'>&nbsp</span>").insertBefore($  cursor);
}
};

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/extra-spaces-being-added-with-on-click-function-through-insertbefore/feed/ 0
How to iterate through a paginated jQuery datatable https://jqueryplugins.info/2011/09/how-to-iterate-through-a-paginated-jquery-datatable/ https://jqueryplugins.info/2011/09/how-to-iterate-through-a-paginated-jquery-datatable/#comments Wed, 14 Sep 2011 01:58:00 +0000 Admin https://jqueryplugins.info/2011/09/how-to-iterate-through-a-paginated-jquery-datatable/ Post link: How to iterate through a paginated jQuery datatable

I have a datatable where in I have set 100 rows to a page. Anyway, with jQuery -sending request to server etc., I have the data filled, for e.g. say...

]]>
Post link: How to iterate through a paginated jQuery datatable

I have a datatable where in I have set 100 rows to a page. Anyway, with jQuery -sending request to server etc., I have the data filled, for e.g. say one of the calls brings in 260 rows. Later when I have to perform some checks for each row for e.g. to see if some values have been selected or something like that, I need to iterate. So when I use fnGetNodes() or fnGetData() both seem to get only the first 100 rows of the table that is the 1st page rows. I want to be able to iterate all the 260 rows, because the user may have paged back and forth and made several selections/changes to the data. Any help is appreciated. I am using jQuery 1.4 version of DataTable.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/how-to-iterate-through-a-paginated-jquery-datatable/feed/ 0
How to pass an array through in JQuery Ajax and how to concieve it in server side? https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/ https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/#comments Mon, 12 Sep 2011 10:13:29 +0000 Admin https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/ Post link: How to pass an array through in JQuery Ajax and how to concieve it in server side?

I have a problem where i have to pass a list of ids to serverside to delete some users, but my requirement is to do it using JQuery Ajax. But...

]]>
Post link: How to pass an array through in JQuery Ajax and how to concieve it in server side?

I have a problem where i have to pass a list of ids to serverside to delete some users, but my requirement is to do it using JQuery Ajax. But I was not able to get the parameters in my server side can anybody give a help on this to sort out pls?

What i have done till now is shown below

  var idList = new Array();
$  (document).ready(function () {
    $  ('input:checkbox').click(function () {
        //set our checkedcount variable to 0
        var checkedCount = 0;
        //loop through and count the number of "checked" boxes
        $  ('.acceptUsers:checked').each(function () {
            //if a checked box was found, increase checkedCount by 1
            idList.push($  (this).val());
            checkedCount++;
        });
    });
});
      $  ('#btnDelete').click(function () {
          url = 'Teacher/UpdateUserStatus/';
          var ids = idList.toString();
          $  .ajax({
              type: "POST",
              url: url,
              data: { 'userIds': ids },
              contentType: "application/json; charset=utf-8",
              dataType: "html",
              success: function (data) {
                  alert('yeah');
                }
              }
          });
      });

What i have done in my server side is

    [HttpPost]
    public JsonResult UpdateUserStatus(object userIds)
    {
        List<int> usersToDelete = new JavaScriptSerializer().ConvertToType<List<int>>(userIds);
        this.userService.DeleteUsers(usersToDelete);
        return Json(true, JsonRequestBehavior.AllowGet);
    }

Can anybody know why my server side method is not calling?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/how-to-pass-an-array-through-in-jquery-ajax-and-how-to-concieve-it-in-server-side/feed/ 0
Javascript: Using setInterval() in conjunction with looping through an array? https://jqueryplugins.info/2011/09/javascript-using-setinterval-in-conjunction-with-looping-through-an-array/ https://jqueryplugins.info/2011/09/javascript-using-setinterval-in-conjunction-with-looping-through-an-array/#comments Thu, 01 Sep 2011 09:46:22 +0000 Admin https://jqueryplugins.info/2011/09/javascript-using-setinterval-in-conjunction-with-looping-through-an-array/ Post link: Javascript: Using setInterval() in conjunction with looping through an array?

Question by jayztttight: Javascript: Using setInterval() in conjunction with looping through an array? Ok so this might potentially be a tough question, keep that in mind. All the effects I...

]]>
Post link: Javascript: Using setInterval() in conjunction with looping through an array?

Question by jayztttight: Javascript: Using setInterval() in conjunction with looping through an array?
Ok so this might potentially be a tough question, keep that in mind. All the effects I explain will be accomplished using jQuery, I only need advice regarding the actual logic.

Ok so basically I have a collection of pictures (which I will be storing in an array), let’s say 5.

Every 12 seconds, I want to fade out the current image, and fade the next one in the array in. If it gets to the very last picture, I want it to go back to the first picture. This needs to be done endlessly. Someone suggested I used setInterval() for this, but I have no idea how to go about this. Any suggestions at all?

Best answer:

Answer by Jeff E
I was just messing around with a crossfade slideshow script yesterday. I used the setTimeout in it and it will loop continuously. Just place this script in the head and call the runSlideShow() with body onload, and give the img tag you want it to appear in an id of “adBanner” or change that in the script to your own id.



Ad Banner


Give your answer to this question below!

]]>
https://jqueryplugins.info/2011/09/javascript-using-setinterval-in-conjunction-with-looping-through-an-array/feed/ 0
Dragging a div through container with overflow.? https://jqueryplugins.info/2011/08/dragging-a-div-through-container-with-overflow/ https://jqueryplugins.info/2011/08/dragging-a-div-through-container-with-overflow/#comments Mon, 29 Aug 2011 02:46:48 +0000 Admin https://jqueryplugins.info/2011/08/dragging-a-div-through-container-with-overflow/ Post link: Dragging a div through container with overflow.?

Question by Foofah: Dragging a div through container with overflow.? Hey all, I am looking for a JQuery solution for the following problem. I have got two divs, one is...

]]>
Post link: Dragging a div through container with overflow.?

Question by Foofah: Dragging a div through container with overflow.?
Hey all,

I am looking for a JQuery solution for the following problem.

I have got two divs, one is a container with an overflow property and within that div another div which is bigger. I want to drag the underlying div through the top div. Example:

#container {
width: 300px;
height: 300px;
overflow: hidden
}
#dragdiv {
width: 700px;
height: 700px;
}

Basically I want to drag the image through the container with the dragdiv.

Best answer:

Answer by Jay Estux
You have to set the css property position to absolute and the you just modify the left and top css properties to position the image/div. You handle the onmousedown event set a boolean variable to true to indicate that dragging has started. on the onmousemove event you modify the left and top properties to move the image only if the boolean flag is true. You handle the onmouseup event to set the flag to false to indicate dragging has ended. The minor details you can figure out yourself.

Give your answer to this question below!

]]>
https://jqueryplugins.info/2011/08/dragging-a-div-through-container-with-overflow/feed/ 0