jQuery Plugins » Adding https://jqueryplugins.info jQuery plugins, tutorials and resources Fri, 21 Oct 2011 16:13:28 +0000 en hourly 1 http://wordpress.org/?v=3.2.1 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
Script for adding a text in the ClipBoard when a User copy some text from my webpage https://jqueryplugins.info/2011/10/script-for-adding-a-text-in-the-clipboard-when-a-user-copy-some-text-from-my-webpage/ https://jqueryplugins.info/2011/10/script-for-adding-a-text-in-the-clipboard-when-a-user-copy-some-text-from-my-webpage/#comments Tue, 04 Oct 2011 06:19:39 +0000 Admin https://jqueryplugins.info/2011/10/script-for-adding-a-text-in-the-clipboard-when-a-user-copy-some-text-from-my-webpage/ Post link: Script for adding a text in the ClipBoard when a User copy some text from my webpage

I use Asp.net and C# 4, but I suppose for this question I need some JavaScript (maybe jquery). I have a Web Page, when a User copy some text from...

]]>
Post link: Script for adding a text in the ClipBoard when a User copy some text from my webpage

I use Asp.net and C# 4, but I suppose for this question I need some JavaScript (maybe jquery).

I have a Web Page, when a User copy some text from the page, I would like that in his Clipboards will be added some custom Text, for example the source URL where he copied it from.
In this way when he PAST the text he can see the original Text + The custom Text added.

An example of implementation you can find here. Simple Copy and Pase from this page to a Text File and you can see what I need.

http://www.miamiherald.com/2011/10/03/2437413/asian-markets-lower-on-greek-debt.html

Any idea how to do it? Any reference? Thanks for your time on this.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/script-for-adding-a-text-in-the-clipboard-when-a-user-copy-some-text-from-my-webpage/feed/ 0
Adding new input:checkbox and not has value https://jqueryplugins.info/2011/10/adding-new-inputcheckbox-and-not-has-value/ https://jqueryplugins.info/2011/10/adding-new-inputcheckbox-and-not-has-value/#comments Sun, 02 Oct 2011 18:13:44 +0000 Admin https://jqueryplugins.info/2011/10/adding-new-inputcheckbox-and-not-has-value/ Post link: Adding new input:checkbox and not has value

I have problem in add new input:checkbox, when i adding new input and checked on it next setup clicked on button i not have value for input:checkbox that was checked....

]]>
Post link: Adding new input:checkbox and not has value

I have problem in add new input:checkbox, when i adding new input and checked on it next setup clicked on button i not have value for input:checkbox that was checked. how is fix it?

DEMO: http://jsfiddle.net/G4QRp/

$  (function () {
    $  ('a.add_input').live('click', function (event) {
        event.preventDefault();
        var $  class = '.' + $  (this).closest('div.find_input').find('div').attr('class').split(" ")[0];
        var size_un = $  ($  class).length;
        var $  this = $  (this),
            $  div = $  this.closest($  class),
            $  clone = $  div.clone().hide().insertAfter($  div).fadeIn('slow');
        $  clone.find('.adda').not(':has(.remove_input)').append('<div class="mediumCell"><a href="" class="remove_input"></a></div>');
        $  clone.find('input').val('').prop('checked', false);
        $  this.remove();
        var size_un = $  ($  class).length---1;
        $  ($  class + ':last input:checkbox').prop('name', 'checkbox_units[' + size_un + '][]');
        console.log($  ($  class + ':last input:checkbox').prop('name'));
    });
});

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/10/adding-new-inputcheckbox-and-not-has-value/feed/ 0
Adding and finding classes that is dynamically added to body – jquery https://jqueryplugins.info/2011/09/adding-and-finding-classes-that-is-dynamically-added-to-body-jquery/ https://jqueryplugins.info/2011/09/adding-and-finding-classes-that-is-dynamically-added-to-body-jquery/#comments Tue, 27 Sep 2011 15:17:12 +0000 Admin https://jqueryplugins.info/2011/09/adding-and-finding-classes-that-is-dynamically-added-to-body-jquery/ Post link: Adding and finding classes that is dynamically added to body – jquery

Is there any way to add classes or alter objects that is dynamically added to the body? I am adding a range of objects to the body by javascript. Fot...

]]>
Post link: Adding and finding classes that is dynamically added to body – jquery

Is there any way to add classes or alter objects that is dynamically added to the body?

I am adding a range of objects to the body by javascript.
Fot instance Im adding some links that is dynamically generated and added to the body. When they are loaded I need to elect the first of the divs and add a new class to it.

I can’t seem to find any way to do this… Update the DOM or how should I go around this? There must be a way to alter dynamically added objects.

Any clues?

Thanks for any help!

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/adding-and-finding-classes-that-is-dynamically-added-to-body-jquery/feed/ 0
Adding element before a div with title attribute containing content of the div using JQuery https://jqueryplugins.info/2011/09/adding-element-before-a-div-with-title-attribute-containing-content-of-the-div-using-jquery/ https://jqueryplugins.info/2011/09/adding-element-before-a-div-with-title-attribute-containing-content-of-the-div-using-jquery/#comments Sat, 24 Sep 2011 01:15:42 +0000 Admin https://jqueryplugins.info/2011/09/adding-element-before-a-div-with-title-attribute-containing-content-of-the-div-using-jquery/ Post link: Adding element before a div with title attribute containing content of the div using JQuery

I have: <li class="ingredient"> <div> <span class="amount">1 lb</span> <span class="name">asparagus</span> </div> i want to use jQuery to get: <li class="ingredient"> <img class="myImage" title="Yes!!! asparagus" src="/white2x2.gif"> <div> <span class="amount">1 lb</span> <span...

]]>
Post link: Adding element before a div with title attribute containing content of the div using JQuery

I have:

<li class="ingredient">
<div>
<span class="amount">1 lb</span>
<span class="name">asparagus</span>
</div>

i want to use jQuery to get:

<li class="ingredient">
<img class="myImage" title="Yes!!! asparagus" src="/white2x2.gif">
<div>
<span class="amount">1 lb</span>
<span class="name">asparagus</span>
</div>

so far I got:

 $  (".ingredient div").before("<class='myImage' src="/white2x2.gif' />");

but how do I get the title in there. Note that there is lots of these on the page and I want the title to represent the element.

Many thanks!

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/adding-element-before-a-div-with-title-attribute-containing-content-of-the-div-using-jquery/feed/ 0
Adding dynamic html to modal causes window to scroll up https://jqueryplugins.info/2011/09/adding-dynamic-html-to-modal-causes-window-to-scroll-up/ https://jqueryplugins.info/2011/09/adding-dynamic-html-to-modal-causes-window-to-scroll-up/#comments Thu, 22 Sep 2011 19:16:39 +0000 Admin https://jqueryplugins.info/2011/09/adding-dynamic-html-to-modal-causes-window-to-scroll-up/ Post link: Adding dynamic html to modal causes window to scroll up

Explanation: I have a modal that pops up when an html element is clicked. The modal is then appended to the document body and is positioned absolute. The top and...

]]>
Post link: Adding dynamic html to modal causes window to scroll up

Explanation: I have a modal that pops up when an html element is clicked. The modal is then appended to the document body and is positioned absolute. The top and left css attributes are set based of the element’s offset that was clicked to trigger the modal.

Problem: The modal fires properly and is positioned appropriately. There is a button within the modal that has a click function that adds further markup to the modal. When the button is pressed the markup is added correctly, but if the window is scrolled to any position, the window scrolls directly to the top.

What is the cause of the window scrolling and how can I prevent it from happening?

Thanks.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/adding-dynamic-html-to-modal-causes-window-to-scroll-up/feed/ 0
Adding properties to a existing object https://jqueryplugins.info/2011/09/adding-properties-to-a-existing-object/ https://jqueryplugins.info/2011/09/adding-properties-to-a-existing-object/#comments Tue, 13 Sep 2011 11:19:19 +0000 Admin https://jqueryplugins.info/2011/09/adding-properties-to-a-existing-object/ Post link: Adding properties to a existing object

thsi is not a jquery ui question but a JavaScript object question function uiDialog() { ............... ............... $ ('#dialog ').dialog({ width:'auto', height :'auto', resizable: false }); .............. .............. } Above...

]]>
Post link: Adding properties to a existing object

thsi is not a jquery ui question but a JavaScript object question

function uiDialog()
{
   ...............
   ...............

    $  ('#dialog ').dialog({
        width:'auto',
        height :'auto',
        resizable: false
    });
    ..............
    ..............
}

Above is a jquery ui dialog code. Now everywhere i want a dialog am calling uiDialog(). Now ui has so many options that are rarely required. So i am considering passing a object as a parameter and appending it to this default data but how can i do it .can i do

$  ('#dialog ').dialog({
    width:'auto',
    height :'auto',
    resizable: false,
    myObject
});

Will this work or can you suggest any other way if this fails

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/adding-properties-to-a-existing-object/feed/ 0
Preventing jquery’s show/hide from adding inline style? https://jqueryplugins.info/2011/09/preventing-jquerys-showhide-from-adding-inline-style/ https://jqueryplugins.info/2011/09/preventing-jquerys-showhide-from-adding-inline-style/#comments Sun, 11 Sep 2011 18:26:17 +0000 Admin https://jqueryplugins.info/2011/09/preventing-jquerys-showhide-from-adding-inline-style/ Post link: Preventing jquery’s show/hide from adding inline style?

I have a case where I need to toggle the visibility of an element based on whether a particular operation (categorization) is in progress if so, it’s hidden, else it’s...

]]>
Post link: Preventing jquery’s show/hide from adding inline style?

I have a case where I need to toggle the visibility of an element based on whether a particular operation (categorization) is in progress if so, it’s hidden, else it’s visible.

Now I have css which looks like this:

.isCategorizing .category.all {
   display:none;
}

i.e., it means that that div with class(es) .category.all should be hidden if it’s parent(s) have the class .isCategorizing

Now in jquery if I toggle the visibility of the .category.all element an inline style is added to the HTML taking precedence over the CSS in the .css file!! So even if the above is true the visibility value from the inline style seems to take precedence and the element is NOT hidden. On being visible jquery add’s style=display:list-item; to the div whereas my CSS should make it hidden…

I could handle this in pure jQuery but there are too many states and checks to make sure that it should work in that particular manner as well as maintain a boolean flag to “remember” if that state existed and whether to revert to that state ever. The CSS approach is simpler and much cleaner, but the inline style is the irritating bit…

…how best to deal with this? I tried creating another class .hide and toggled that with jquery. Seems to work but for some reason screws up the positioning of my element. I’m playing with it but can’t seem to find a clean solution to this problem. Any advice??

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/preventing-jquerys-showhide-from-adding-inline-style/feed/ 0
How to change Div Id value when adding rows to a table https://jqueryplugins.info/2011/09/how-to-change-div-id-value-when-adding-rows-to-a-table/ https://jqueryplugins.info/2011/09/how-to-change-div-id-value-when-adding-rows-to-a-table/#comments Sun, 11 Sep 2011 08:15:41 +0000 Admin https://jqueryplugins.info/2011/09/how-to-change-div-id-value-when-adding-rows-to-a-table/ Post link: How to change Div Id value when adding rows to a table

Ok. So I have a problem and the solution to this problem is just a little bit beyond my programming ability… Hopefully someone can help me. I have a table...

]]>
Post link: How to change Div Id value when adding rows to a table

Ok. So I have a problem and the solution to this problem is just a little bit beyond my programming ability… Hopefully someone can help me.

I have a table with a div inside each cell. I need the div id to dynamically change whenever a row or a column is added to the table. The div id’s snake around the table, so when a new row or column is added, the div ids have to change. The div ids are used in the javascript, so they have to dynamically change or the code won’t work.

I created picture examples of everything, but since I’m a new member I can’t add them. Hopefully my text example below will help you to see what i mean…

2X2 Table with div ids that snake back around:

| div id = 1 | div id = 2 |
| div id = 4 | div id = 3 |

2X3 table with a new column added with how the div ids need to look:

| div id = 1 | div id = 2 | div id = 3 |
| div id = 6 | div id = 5 | div id = 4 |


Thank you so much!

Also if you have another idea in mind of how this could work, let me know. I’m open to all suggestions.

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/how-to-change-div-id-value-when-adding-rows-to-a-table/feed/ 0
Adding variables together returns string rather than number https://jqueryplugins.info/2011/09/adding-variables-together-returns-string-rather-than-number/ https://jqueryplugins.info/2011/09/adding-variables-together-returns-string-rather-than-number/#comments Mon, 05 Sep 2011 22:13:40 +0000 Admin https://jqueryplugins.info/2011/09/adding-variables-together-returns-string-rather-than-number/ Post link: Adding variables together returns string rather than number

I’ve got three variables I’m trying to sum the values. For two of these items, I need the form value to read differently, so i’ve created an attribute cost to...

]]>
Post link: Adding variables together returns string rather than number

I’ve got three variables I’m trying to sum the values. For two of these items, I need the form value to read differently, so i’ve created an attribute cost to pull the cost through with. My code is:

var opt1 = parseFloat($  ('#ac1 option:selected').attr('cost')).toFixed(2);
var opt2 = parseFloat($  ('#ac2 option:selected').attr('cost')).toFixed(2);
var base = parseFloat($  ('#original_price').val());
var newprice = opt1+opt2+base;

if opt1 should be 4.00, opt2 6.50 and base 10.00, it’s giving me an output of 4.006.5010.00 instead of 20.50

any ideas on where i’m going wrong?

newest questions tagged jquery – Stack Overflow

]]>
https://jqueryplugins.info/2011/09/adding-variables-together-returns-string-rather-than-number/feed/ 0