Thursday, April 30, 2009

[jQuery] Re: tablesorter.js vs Numerals with Commas

Hi,
I am posted a similar question where I am getting a null or not an object
error on .hml() in IE
Perhaps you can help. I am trying to build a custom parser that will extract
the data from a span


ts.addParser({
id: "empnames",
is: function(s) {
return false;
},
format: function(s) {

var strobj = $($.trim(s));

return
strobj.find("span").html().toLowerCase();
},
type: "text"
});

In that case strobj.find("span") is an object but as soon as I add .html()
it returns null
in IE. It works fine in Safari and Firefox. I am using jQuery 1.3.2 and
tablesorter 2.0
If anyone has a better technique to do it it's also appreciated.

Thanks


aquaone wrote:
>
> There are two simple ways of fixing this: having a hidden span or similar
> element appearing within your td prior to the value or better to define
> your
> own parser.
>
> e.g.
> $.tablesorter.addParser({
> id: "commaNum",
> is: function(s) {
> return /^[\d-]?[\d,]*(\.\d+)?$/.test(s);
> },
> format: function(s) {
> return s.replace(/,/g,'');
> },
> type: 'numeric'
> });
>
> aquaone
> (yes, you could use a more precise regex...)
>
>
> On Wed, Apr 29, 2009 at 20:41, David Blomstrom
> <david.blomstrom@gmail.com>wrote:
>
>> I'm using jQuery's tablesorter.js to create tables with sortable rows. It
>> works fine on both text and numerals - but only if they have no commas.
>> For
>> example, the following column would sort properly:
>> 2
>> 18
>> 401
>> 3
>> 15
>> But this column...
>> 1,200
>> 408
>> 26,048
>> ...would sort like this:
>> 1,200
>> 26,048
>> 408
>> Does anyone know how to fix this?
>> I'm using PHP and MySQL to derive my data from a database table, using
>> the
>> following code:
>> $Area = number_format($row["Area"]);
>> Then I simply insert $Area in a dynamic table cell, like so...
>> <td>$Area</td>
>> I posted my JavaScript links below. Thanks for any tips!
>> * * * * *
>> <script src="http://MySite/js/jquery-1.3.1.min.js"
>> type="text/javascript"></script>
>> <script src="http://MySite/js/tablesorter/jquery.tablesorter.js"
>> type="text/javascript"></script>
>> <script language="JavaScript" type="text/JavaScript">
>> $(document).ready(function()
>> {
>> $("#myTable").tablesorter({ widgets: ['zebra']} );
>>
>> $("#triggerMS").click(function(){
>> $("#menuMS").show();
>> return false;
>> });
>> $("#menuMS").click( function(){
>> $("#menuMS").hide();
>> return true;
>> });
>>
>> $("#triggerReg").click(function(){
>> $("#menuReg").show();
>> return false;
>> });
>> $("#menuReg").click( function(){
>> $("#menuReg").hide();
>> return true;
>> });
>>
>> $("#triggerKids").click(function(){
>> $("#menuKids").show();
>> return false;
>> });
>> $("#menuKids").click( function(){
>> $("#menuKids").hide();
>> return true;
>> });
>>
>> $("#triggerLinks").click(function(){
>> $("#menuLinks").show();
>> return false;
>> });
>> $("#menuLinks").click( function(){
>> $("#menuLinks").hide();
>> return true;
>> });
>>
>> $("#triggerBooks").click(function(){
>> $("#menuBooks").show();
>> return false;
>> });
>> $("#menuBooks").click( function(){
>> $("#menuBooks").hide();
>> return true;
>> });
>>
>> }
>> );
>> </script>
>>
>> --
>> David Blomstrom
>> Writer & Web Designer (Mac, M$ & Linux)
>> www.geobop.org
>>
>
>

--
View this message in context: http://www.nabble.com/tablesorter.js-vs-Numerals-with-Commas-tp23309424s27240p23325353.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

[jQuery] Re: generated content(PHP) into DIV?

Hi there,

Here is a very simple implementation of what you are talking about - it
assumes you have three divs in the markup with IDs 'place', 'house', and
'level', and that you load content for these from 'places.php', houses.php'
and 'levels.php' respectively. It also assumes that the PHP files simply
return HTML fragments (lists).

$(function(){
// load the first list when the document loads
$('#place').load('places.php',{},function(){
// 'this' holds a reference to the dom content loaded, so attach a
click handler to each list item
$('li', this).click(function(){
// when a list item is clicked, pass the text of the item to
houses.php, and load in #house

$('#house').load('houses.php',{'place':$(this).text()},function(){
// do the same thing with the loaded list
$('li', this).click(function(){
// do the same again when this level is clicked
$('#level').load('levels.php',{'house':$(this).text()},
function(){
// now you need logic to handle clicks on elements
in the #level list items
});
});
});
})
});
});

Although this is a working example / proof of concept, I'm sure there has to
be a more elegant way of doing it (with a plugin?)


Tony-182 wrote:
>
>
> Hello Everyone!
>
> I have 3 DIV's next to each other. I want that the first div is loaded
> over jquery with a php file which outputs an unordered list in html.
>
> When I click on a list item in the first DIV I want that jquery sends
> the parameters from the list to a second php file for making an
> unordered list which is loaded this time into the second DIV.
>
> The same should happen from the second DIV into the third DIV whith a
> third php file.
>
>
> All php files connect to a mysql database which has three tables
> (Place, House, Level). The tables have three columns(id, name,
> location). location is always linked to the next table's id (ex.
> "sesame street 1" has id 37 then tabel Place would have folowing
> entry: id=1 name=Stockholm location=37 )
>
> The purpose of this script is to navigate though houses in different
> places. The 3 DIV's contain following.
> DIV 1 = Place (ex. Stockholm, Berlin, Barcelona)
> DIV 2 = House (sesame street 1, sesame street 2, sesame street 3)
> DIV 3 = Level (Floor 1, Floor 2, Floor 3)
>
> I really tried all things in jquery from appendTo to $.ajax but I just
> dont get it working! The three divs are easy to create but getting the
> content dynamically into them seems quite impossible. Please help me,
> I tride really long to solve this problem but I just don't seem to get
> it, hope someone can help me :(
>
>

--
View this message in context: http://www.nabble.com/generated-content%28PHP%29-into-DIV--tp23318863s27240p23325009.html
Sent from the jQuery General Discussion mailing list archive at Nabble.com.

[jQuery] Re: tablesorter.js vs Numerals with Commas

There are two simple ways of fixing this: having a hidden span or similar element appearing within your td prior to the value or better to define your own parser.

e.g.
  $.tablesorter.addParser({
    id: "commaNum",
    is: function(s) {
      return /^[\d-]?[\d,]*(\.\d+)?$/.test(s);
      },
    format: function(s) {
      return s.replace(/,/g,'');
      },
    type: 'numeric'
    });

aquaone
(yes, you could use a more precise regex...)


On Wed, Apr 29, 2009 at 20:41, David Blomstrom <david.blomstrom@gmail.com> wrote:
I'm using jQuery's tablesorter.js to create tables with sortable rows. It works fine on both text and numerals - but only if they have no commas. For example, the following column would sort properly:
2
18
401
3
15
But this column...
1,200
408
26,048
...would sort like this:
1,200
26,048
408
Does anyone know how to fix this?
I'm using PHP and MySQL to derive my data from a database table, using the following code:
$Area = number_format($row["Area"]);
Then I simply insert $Area in a dynamic table cell, like so...
<td>$Area</td>
I posted my JavaScript links below. Thanks for any tips!
* * * * *
<script src="http://MySite/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="http://MySite/js/tablesorter/jquery.tablesorter.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
 $(document).ready(function() 
  { 
  $("#myTable").tablesorter({ widgets: ['zebra']} );

$("#triggerMS").click(function(){
 $("#menuMS").show();
 return false;
});
$("#menuMS").click( function(){
 $("#menuMS").hide();
 return true;
});

$("#triggerReg").click(function(){
 $("#menuReg").show();
 return false;
});
$("#menuReg").click( function(){
 $("#menuReg").hide();
 return true;
});

$("#triggerKids").click(function(){
 $("#menuKids").show();
 return false;
});
$("#menuKids").click( function(){
 $("#menuKids").hide();
 return true;
});

$("#triggerLinks").click(function(){
 $("#menuLinks").show();
 return false;
});
$("#menuLinks").click( function(){
 $("#menuLinks").hide();
 return true;
});

$("#triggerBooks").click(function(){
 $("#menuBooks").show();
 return false;
});
$("#menuBooks").click( function(){
 $("#menuBooks").hide();
 return true;
});

  }
 );
</script>

--
David Blomstrom
Writer & Web Designer (Mac, M$ & Linux)
www.geobop.org

[jQuery] Re: Zebra (stripes) Widget vs Colgroups (CSS)

<tr> style is overriding the <colgroup> style.

Perhaps this diagram will explain it well.
http://www.w3.org/TR/CSS21/tables.html#table-layers

aquaone


On Wed, Apr 29, 2009 at 20:30, David Blomstrom <david.blomstrom@gmail.com> wrote:
I'm using jQuery and the Zebra widget to produce alternately colored rows on my tables. It works great but it kills my CSS colgroup functions. For example, the following code...
<table class="sortphp" id="myTable">
<colgroup style="background: #0ff;"></colgroup>
<colgroup style="background: #ff0;"></colgroup>
<thead>
...should produce a table where every cell in the first column is aqua, every cell in the second yellow. But if my Zebra widget dictates that alternate rows are gray and white, then EVERY cell in every row and column is either gray and white.
Does anyone know if there's a way to reverse the relationship, so that colgroups trump alternate row colors? It isn't absolutely critical, as I could probably accomplish my goal by simply assigning each cell a class (e.g. <td class="red">), but I'd prefer to use colgroups for bigger tables.
I posted my JavaScript links below. Thanks.
* * * * *
<script src="http://MySite/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="http://MySite/js/tablesorter/jquery.tablesorter.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
 $(document).ready(function() 
  { 
  $("#myTable").tablesorter({ widgets: ['zebra']} );

$("#triggerMS").click(function(){
 $("#menuMS").show();
 return false;
});
$("#menuMS").click( function(){
 $("#menuMS").hide();
 return true;
});

$("#triggerReg").click(function(){
 $("#menuReg").show();
 return false;
});
$("#menuReg").click( function(){
 $("#menuReg").hide();
 return true;
});

$("#triggerKids").click(function(){
 $("#menuKids").show();
 return false;
});
$("#menuKids").click( function(){
 $("#menuKids").hide();
 return true;
});

$("#triggerLinks").click(function(){
 $("#menuLinks").show();
 return false;
});
$("#menuLinks").click( function(){
 $("#menuLinks").hide();
 return true;
});

$("#triggerBooks").click(function(){
 $("#menuBooks").show();
 return false;
});
$("#menuBooks").click( function(){
 $("#menuBooks").hide();
 return true;
});

  }
 );
</script>
--
David Blomstrom
Writer & Web Designer (Mac, M$ & Linux)
www.geobop.org

[jQuery] Re: Applying Table Row Sorter to Multiple Tables

IDs are unique for a document. A document containing multiple elements with the same ID is invalid. Use a class instead and invoke tablesorter on all tables with that class.

e.g.
<table class="tablesorter">
...
</table>

and

$("table.tablesorter").tablesorter({ widgets: ['zebra'] });



On Wed, Apr 29, 2009 at 20:35, David Blomstrom <david.blomstrom@gmail.com> wrote:
I'm using jQuery's tablesorter.js to create tables with sortable rows, as applied to tables with the ID "myTable."
I just wondered if there's a way to make it work with multiple tables on a single page. I created two tables and gave each of them the ID myTable, but only the first table worked. I can't remember if the specific ID is required for my Zebra widget (alternate row colors), too, or not, but I would guess it is.
I posted my JS links below, to show you my setup. Thanks for any tips.
* * * * *
<script src="http://MySite/js/jquery-1.3.1.min.js" type="text/javascript"></script>
<script src="http://MySite/js/tablesorter/jquery.tablesorter.js" type="text/javascript"></script>
<script language="JavaScript" type="text/JavaScript">
 $(document).ready(function() 
  { 
  $("#myTable").tablesorter({ widgets: ['zebra']} );

$("#triggerMS").click(function(){
 $("#menuMS").show();
 return false;
});
$("#menuMS").click( function(){
 $("#menuMS").hide();
 return true;
});

$("#triggerReg").click(function(){
 $("#menuReg").show();
 return false;
});
$("#menuReg").click( function(){
 $("#menuReg").hide();
 return true;
});

$("#triggerKids").click(function(){
 $("#menuKids").show();
 return false;
});
$("#menuKids").click( function(){
 $("#menuKids").hide();
 return true;
});

$("#triggerLinks").click(function(){
 $("#menuLinks").show();
 return false;
});
$("#menuLinks").click( function(){
 $("#menuLinks").hide();
 return true;
});

$("#triggerBooks").click(function(){
 $("#menuBooks").show();
 return false;
});
$("#menuBooks").click( function(){
 $("#menuBooks").hide();
 return true;
});

  }
 );
</script>


--
David Blomstrom
Writer & Web Designer (Mac, M$ & Linux)
www.geobop.org


--
David Blomstrom
Writer & Web Designer (Mac, M$ & Linux)
www.geobop.org

[jQuery] Re: Why would an id become undefined?

Thanks for your reply.

It turns out that the bug was that I am going blind. The case of the
id was mistyped. A different font style, size or glasses may have
helped (or a debugging tool that shows all id's in a document and if
they are in fact unique):
hid hId
hId hid

[jQuery] Re: suppressing toggle on link click

Does anyone know how to accomplish what Christopher is asking? I have
the exact same question as I want my treeview to expand/collapse when
the +/- are clicked but not the node's title.

Thanks,
Ryan

On Apr 13, 3:10 pm, Christopher Litsinger <g33k.m...@gmail.com> wrote:
> I'm using the jquery.treeviewplugin to build an outline.  Each
> element within the outline has a link to the side of it that runs a
> javascript function.  I'd like to have users click on this without
> triggering the toggle of the element.
>
> Below is a very simple html file that shows the problem- each element
> has a [+] to the side of it- when you click on that link, in addition
> to the alert, the group will expand or contract.  Any ideas how to
> suppress that when clicking on the [+], but allow it when clicking on
> the text itself?
>
> <html>
> <head>
> <script src='jquery/jquery.js' type='text/javascript'></script>
> <script src='jquery/jquery-treeview/jquery.treeview.js' type='text/
> javascript'></script>
> <script src='jquery/jquery.cookie.js' type='text/javascript'></script>
> <script language="JavaScript">
> $(document).ready(function(){
>         $("#outline").treeview({
>                 animated: "fast",
>                 collapsed: false,
>                 unique: false,
>                 persist: "cookie",
>                 toggle: function() {
>                         window.console && console.log("%o was toggled", this);
>                 }
>         });
>
> });
>
> </script>
> <link rel="stylesheet" href="jquery/jquery-treeview/
> jquery.treeview.css" type="text/css" media="screen" />
>
> </head>
> <body>
> <ul id="outline" class="treeview-red">
>   <li><span>top element <a href="javascript:void(0);" onClick="alert
> ('hi');">[+]</a></span>
>     <ul>
>     <li><span>level 1 element 1<a href="javascript:void(0);"
> onClick="alert('hi');">[+]</a></span>
>       <ul>
>       <li><span>level 2 element 1 <a href="javascript:void(0);"
> onClick="alert('hi');">[+]</a></span></li>
>       <li><span>level 2 element 2 <a href="javascript:void(0);"
> onClick="alert('hi');');">[+]</a></span>
>       </ul>
>     </li>
> </ul>
> </body>
> </html>

[jQuery] Re: Confirmation alert fires multiple times with jQuery click

strange, but now it prints just "x", without included HTML.

[jQuery] Re: Confirmation alert fires multiple times with jQuery click

Sorry about that too!
Try:

$(this).before('<p>'+$close.html()+'</p>');

Just note that $close is an actual jQuery object, so you can do
whatever jQuery stuff you want to it, such as attach events, append
text, etc.

On Apr 30, 9:33 am, st <s...@studio.ee> wrote:
> nope, when this function executes: $(this).before('<p>'+$close+'</
> p>');
> it gives: [object Object]
> :)
>
> On Apr 30, 10:18 pm, James <james.gp....@gmail.com> wrote:
>
> > Sorry. Maybe this:
>
> >         function addtag() {
> >                 var $close = $('<b class="close">x</b>');  // wrap as
> > jquery object
> >                 $close.click(function() {
> >                         if (confirm('Are you sure you want to remove
> > this?')){
> >                                 $(this).remove();
> >                         }
> >                 });
> >                 $(this).before('<p>'+$close+'</p>');
>
> >         }
>
> > On Apr 30, 9:02 am, st <s...@studio.ee> wrote:
>
> > > The second method does not allow to assign a click to variable. I get
> > > an error.
> > > But hack-ish method at least works, thanks! :)
>
> > > On Apr 30, 9:55 pm, James <james.gp....@gmail.com> wrote:
>
> > > > That's because you are binding the event again to all existing
> > > > elements with class "close".
>
> > > > A real hack-ish workaround is doing:
> > > > $(".close").unbind("click").bind("click", function() { ...
> > > > (this unbind all the click and rebinds them again)
>
> > > > A more elegant solution is to bind it only to the element you're
> > > > creating (untested).
>
> > > >         function addtag() {
> > > >                 var $close = '<b class="close">x</b>';
> > > >                 $close.click(function() {
> > > >                         if (confirm('Are you sure you want to remove
> > > > this?')){
> > > >                                 $(this).remove();
> > > >                         }
> > > >                 });
> > > >                 $(this).before('<p>'+$close+'</p>');
>
> > > >         }
>
> > > > On Apr 30, 7:24 am, st <s...@studio.ee> wrote:
>
> > > > > I add multiple items with each click and then I want to remove them
> > > > > one by one by clicking.
>
> > > > > All is ok, but if I add 2-3 items and the click the first one,
> > > > > confirmation alert fires multiple times when i click Cancel.
> > > > > The number of times depends on how many items goes after curent.
>
> > > > > Please help to fix that :)
>
> > > > > Code:
> > > > > -----------------------------
> > > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> > > > > TR/html4/strict.dtd">
> > > > > <html>
> > > > > <head>
> > > > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > > > > <title>test</title>
> > > > > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> > > > > libs/jquery/1.3/jquery.min.js"></script>
> > > > > <script type="text/javascript">
> > > > > <!--
> > > > > $(function() {
> > > > >         function addtag() {
>
> > > > >                 $(this).before('<p><b class="close">x</b></p>');
>
> > > > >                 $(".close").click(function() {
> > > > >                         if (confirm('Are you sure you want to remove this?')){
> > > > >                                 $(this).remove();
> > > > >                         }
> > > > >                 });
>
> > > > >         }
> > > > > $(":button").click(addtag);});
>
> > > > > -->
> > > > > </script>
> > > > > <style type="text/css">
> > > > > <!--
> > > > > body { padding:30px; }
> > > > > div { width:30em; margin:0 auto; }
> > > > > p { margin:0 0 9px; }
> > > > > p b { text-decoration:underline; color:#06F; font-weight:400;
> > > > > cursor:pointer; }
> > > > > -->
> > > > > </style>
> > > > > </head>
> > > > > <body>
> > > > > <div>
>
> > > > > <input type="button" value="click">
>
> > > > > </div>
> > > > > </body>
> > > > > </html>- Hide quoted text -
>
> > > > - Show quoted text -- Hide quoted text -
>
> > - Show quoted text -

[jQuery] Re: Animate Variable Concatenate Help

I tried that initially. It didn't work. I think my variable isn't
being recognized by the second half of my function. I get this error
in firebug.. "mywidth is not defined". But if I alert it in the upper
half I get a value.


On Apr 30, 2:15 pm, pete higgins <phigg...@gmail.com> wrote:
> $(this).animate({ width: mywidth + "px" });
>
> think:
>
> var newwidth = {
>    "width": mywidth + "px"
>
> }
>
> Regards
>
> On Thu, Apr 30, 2009 at 5:54 PM, paper_robots <mresto...@gmail.com> wrote:
>
> > I'm trying to get the width of an element, animate it bigger, then
> > shrink it back to normal size on hover. Here's my function:
>
> > $('a.slider').hover(function(){
> >                var mywidth = $(this).width();
> >                $(this).animate({width: "240px"});
> >        }, function(){
> >                $(this).animate({width: +mywidth+px"});
> >        });
>
> > The line I'm having trouble with is:
> > $(this).animate({width: +mywidth+px"});
>
> > I know its not concatenated right, but I tried a few ways and couldn't
> > get it to work. What am I doing wrong? Thanks in advanced!

[jQuery] Re: Confirmation alert fires multiple times with jQuery click

nope, when this function executes: $(this).before('<p>'+$close+'</
p>');
it gives: [object Object]
:)

On Apr 30, 10:18 pm, James <james.gp....@gmail.com> wrote:
> Sorry. Maybe this:
>
>         function addtag() {
>                 var $close = $('<b class="close">x</b>');  // wrap as
> jquery object
>                 $close.click(function() {
>                         if (confirm('Are you sure you want to remove
> this?')){
>                                 $(this).remove();
>                         }
>                 });
>                 $(this).before('<p>'+$close+'</p>');
>
>         }
>
> On Apr 30, 9:02 am, st <s...@studio.ee> wrote:
>
>
>
> > The second method does not allow to assign a click to variable. I get
> > an error.
> > But hack-ish method at least works, thanks! :)
>
> > On Apr 30, 9:55 pm, James <james.gp....@gmail.com> wrote:
>
> > > That's because you are binding the event again to all existing
> > > elements with class "close".
>
> > > A real hack-ish workaround is doing:
> > > $(".close").unbind("click").bind("click", function() { ...
> > > (this unbind all the click and rebinds them again)
>
> > > A more elegant solution is to bind it only to the element you're
> > > creating (untested).
>
> > >         function addtag() {
> > >                 var $close = '<b class="close">x</b>';
> > >                 $close.click(function() {
> > >                         if (confirm('Are you sure you want to remove
> > > this?')){
> > >                                 $(this).remove();
> > >                         }
> > >                 });
> > >                 $(this).before('<p>'+$close+'</p>');
>
> > >         }
>
> > > On Apr 30, 7:24 am, st <s...@studio.ee> wrote:
>
> > > > I add multiple items with each click and then I want to remove them
> > > > one by one by clicking.
>
> > > > All is ok, but if I add 2-3 items and the click the first one,
> > > > confirmation alert fires multiple times when i click Cancel.
> > > > The number of times depends on how many items goes after curent.
>
> > > > Please help to fix that :)
>
> > > > Code:
> > > > -----------------------------
> > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> > > > TR/html4/strict.dtd">
> > > > <html>
> > > > <head>
> > > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > > > <title>test</title>
> > > > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> > > > libs/jquery/1.3/jquery.min.js"></script>
> > > > <script type="text/javascript">
> > > > <!--
> > > > $(function() {
> > > >         function addtag() {
>
> > > >                 $(this).before('<p><b class="close">x</b></p>');
>
> > > >                 $(".close").click(function() {
> > > >                         if (confirm('Are you sure you want to remove this?')){
> > > >                                 $(this).remove();
> > > >                         }
> > > >                 });
>
> > > >         }
> > > > $(":button").click(addtag);});
>
> > > > -->
> > > > </script>
> > > > <style type="text/css">
> > > > <!--
> > > > body { padding:30px; }
> > > > div { width:30em; margin:0 auto; }
> > > > p { margin:0 0 9px; }
> > > > p b { text-decoration:underline; color:#06F; font-weight:400;
> > > > cursor:pointer; }
> > > > -->
> > > > </style>
> > > > </head>
> > > > <body>
> > > > <div>
>
> > > > <input type="button" value="click">
>
> > > > </div>
> > > > </body>
> > > > </html>- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -

[jQuery] Re: Confirmation alert fires multiple times with jQuery click

Sorry. Maybe this:

function addtag() {
var $close = $('<b class="close">x</b>'); // wrap as
jquery object
$close.click(function() {
if (confirm('Are you sure you want to remove
this?')){
$(this).remove();
}
});
$(this).before('<p>'+$close+'</p>');

}

On Apr 30, 9:02 am, st <s...@studio.ee> wrote:
> The second method does not allow to assign a click to variable. I get
> an error.
> But hack-ish method at least works, thanks! :)
>
> On Apr 30, 9:55 pm, James <james.gp....@gmail.com> wrote:
>
> > That's because you are binding the event again to all existing
> > elements with class "close".
>
> > A real hack-ish workaround is doing:
> > $(".close").unbind("click").bind("click", function() { ...
> > (this unbind all the click and rebinds them again)
>
> > A more elegant solution is to bind it only to the element you're
> > creating (untested).
>
> >         function addtag() {
> >                 var $close = '<b class="close">x</b>';
> >                 $close.click(function() {
> >                         if (confirm('Are you sure you want to remove
> > this?')){
> >                                 $(this).remove();
> >                         }
> >                 });
> >                 $(this).before('<p>'+$close+'</p>');
>
> >         }
>
> > On Apr 30, 7:24 am, st <s...@studio.ee> wrote:
>
> > > I add multiple items with each click and then I want to remove them
> > > one by one by clicking.
>
> > > All is ok, but if I add 2-3 items and the click the first one,
> > > confirmation alert fires multiple times when i click Cancel.
> > > The number of times depends on how many items goes after curent.
>
> > > Please help to fix that :)
>
> > > Code:
> > > -----------------------------
> > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> > > TR/html4/strict.dtd">
> > > <html>
> > > <head>
> > > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > > <title>test</title>
> > > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> > > libs/jquery/1.3/jquery.min.js"></script>
> > > <script type="text/javascript">
> > > <!--
> > > $(function() {
> > >         function addtag() {
>
> > >                 $(this).before('<p><b class="close">x</b></p>');
>
> > >                 $(".close").click(function() {
> > >                         if (confirm('Are you sure you want to remove this?')){
> > >                                 $(this).remove();
> > >                         }
> > >                 });
>
> > >         }
> > > $(":button").click(addtag);});
>
> > > -->
> > > </script>
> > > <style type="text/css">
> > > <!--
> > > body { padding:30px; }
> > > div { width:30em; margin:0 auto; }
> > > p { margin:0 0 9px; }
> > > p b { text-decoration:underline; color:#06F; font-weight:400;
> > > cursor:pointer; }
> > > -->
> > > </style>
> > > </head>
> > > <body>
> > > <div>
>
> > > <input type="button" value="click">
>
> > > </div>
> > > </body>
> > > </html>- Hide quoted text -
>
> > - Show quoted text -

[jQuery] Re: Animate Variable Concatenate Help

$(this).animate({ width: mywidth + "px" });

think:

var newwidth = {
"width": mywidth + "px"
}

Regards

On Thu, Apr 30, 2009 at 5:54 PM, paper_robots <mrestorff@gmail.com> wrote:
>
> I'm trying to get the width of an element, animate it bigger, then
> shrink it back to normal size on hover. Here's my function:
>
>
> $('a.slider').hover(function(){
>                var mywidth = $(this).width();
>                $(this).animate({width: "240px"});
>        }, function(){
>                $(this).animate({width: +mywidth+px"});
>        });
>
>
> The line I'm having trouble with is:
> $(this).animate({width: +mywidth+px"});
>
> I know its not concatenated right, but I tried a few ways and couldn't
> get it to work. What am I doing wrong? Thanks in advanced!
>

[jQuery] Re: jquery treeview menu problem

I just figured this one out.

You need to explicitly hide the child ULs for IE to correctly animate
the Treeview. In your CSS set your UL UL to display:none; and you
should be just fine.

On Apr 10, 5:23 am, Titti <prima...@gmail.com> wrote:
> Hi, i'm using jquery treeview (http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
> ) menu in my website and i have a little problem: when i open a page
> from the menu tree,  menu expands completely  and items alignes to the
> left side for a while, the time that page is charghing. I don't know
> why, can u help me? thank you

[jQuery] Re: Confirmation alert fires multiple times with jQuery click

The second method does not allow to assign a click to variable. I get
an error.
But hack-ish method at least works, thanks! :)


On Apr 30, 9:55 pm, James <james.gp....@gmail.com> wrote:
> That's because you are binding the event again to all existing
> elements with class "close".
>
> A real hack-ish workaround is doing:
> $(".close").unbind("click").bind("click", function() { ...
> (this unbind all the click and rebinds them again)
>
> A more elegant solution is to bind it only to the element you're
> creating (untested).
>
>         function addtag() {
>                 var $close = '<b class="close">x</b>';
>                 $close.click(function() {
>                         if (confirm('Are you sure you want to remove
> this?')){
>                                 $(this).remove();
>                         }
>                 });
>                 $(this).before('<p>'+$close+'</p>');
>
>         }
>
> On Apr 30, 7:24 am, st <s...@studio.ee> wrote:
>
>
>
> > I add multiple items with each click and then I want to remove them
> > one by one by clicking.
>
> > All is ok, but if I add 2-3 items and the click the first one,
> > confirmation alert fires multiple times when i click Cancel.
> > The number of times depends on how many items goes after curent.
>
> > Please help to fix that :)
>
> > Code:
> > -----------------------------
> > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> > TR/html4/strict.dtd">
> > <html>
> > <head>
> > <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> > <title>test</title>
> > <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> > libs/jquery/1.3/jquery.min.js"></script>
> > <script type="text/javascript">
> > <!--
> > $(function() {
> >         function addtag() {
>
> >                 $(this).before('<p><b class="close">x</b></p>');
>
> >                 $(".close").click(function() {
> >                         if (confirm('Are you sure you want to remove this?')){
> >                                 $(this).remove();
> >                         }
> >                 });
>
> >         }
> > $(":button").click(addtag);});
>
> > -->
> > </script>
> > <style type="text/css">
> > <!--
> > body { padding:30px; }
> > div { width:30em; margin:0 auto; }
> > p { margin:0 0 9px; }
> > p b { text-decoration:underline; color:#06F; font-weight:400;
> > cursor:pointer; }
> > -->
> > </style>
> > </head>
> > <body>
> > <div>
>
> > <input type="button" value="click">
>
> > </div>
> > </body>
> > </html>- Hide quoted text -
>
> - Show quoted text -

[jQuery] Re: Why would an id become undefined?

Make sure you're including the libraries in the right order. That is:

// include jQuery library
// call jquery.noConflict
// include Prototype or some other libraries
// do your jquery or other code

On Apr 29, 9:17 am, "$(Noob).bee" <dee....@gmail.com> wrote:
> Are there any debugging tools to trace when/where an element id is
> defined and then becomes undefined?
>
> I'm using:
> jQuery 1.3.2 with and without the fix at //http://dev.jquery.com/
> ticket/4420http://www.appelsiini.net/download/jquery.jeditable.mini.jshttp://code.google.com/p/submodal/(old version v1.1 with a common.js
> file)
> scriptaculous 1.8.2http://www.quirksmode.org/js/detect.htmlhttp://yellow5.us/projects/datechooser/DateChooser 2.9
> and a custom call to "events.add(window, 'load', WindowLoad);"
>
> FF 3.0.10, Safari 3.2.1, IE 7
>
> I was thinking the events.add might conflict with jQuery
> (document).ready, but the ready function does get called with and
> without the events.add commented out.
>
> The following works fine in a stand alone page, but when I include it
> in a page with the above libraries, I get undefined.
>
> jQuery.noConflict();
>
> jQuery(document).ready(function(){
>         jQuery('.jeditable_text').editable(function(value, settings){
>                 alert("#hid" + this.id);// #hidPONumber
>                 alert(jQuery("#hidPONumber").val());//undefined
>                 alert(jQuery("#hid" + this.id).val());//undefined
>                 jQuery("#hid" + this.id).val(value);
>                 alert(jQuery("#hid" + this.id).val());//undefined
>                 return(value);
>         });
>
> });

[jQuery] Re: removing jQuery UI draggable revertDuration

Could you post this question to the jQuery UI list

http://groups.google.com/group/jquery-ui

so it's not missed? Thanks.

- Richard

On Thu, Apr 30, 2009 at 1:22 PM, Ty Wangsness <ty@emarketsouth.com> wrote:

I am using jQuery UI's Draggable plugin to allow the user to drag an image from a box onto a google map to set a marker... the image they were dragging then snaps back to the box it was originally inside of.

I'm running the code that updates the map using the draggable's 'dragend' event, but that callback doesn't seem to fire until the draggable has finished reverting to its original position.  I've set the revertDuration to 0, 1, and other small numbers, but there seems to be a minimum duration for its animation.  Is there a way to remove the animation entirely?  The reason it matters is because the marker is set using the latlong the mouse is hovering over at the time of the callback, but the user can't be expected to hold their cursor exactly still for the fraction of a second it takes for the draggable to revert.

Also if there's an easier way to do all of this, I'm all ears... I glanced through the google map API and didn't see any way of dragging something from outside the map into/onto the map.

[jQuery] Re: Confirmation alert fires multiple times with jQuery click

That's because you are binding the event again to all existing
elements with class "close".

A real hack-ish workaround is doing:
$(".close").unbind("click").bind("click", function() { ...
(this unbind all the click and rebinds them again)

A more elegant solution is to bind it only to the element you're
creating (untested).

function addtag() {
var $close = '<b class="close">x</b>';
$close.click(function() {
if (confirm('Are you sure you want to remove
this?')){
$(this).remove();
}
});
$(this).before('<p>'+$close+'</p>');

}

On Apr 30, 7:24 am, st <s...@studio.ee> wrote:
> I add multiple items with each click and then I want to remove them
> one by one by clicking.
>
> All is ok, but if I add 2-3 items and the click the first one,
> confirmation alert fires multiple times when i click Cancel.
> The number of times depends on how many items goes after curent.
>
> Please help to fix that :)
>
> Code:
> -----------------------------
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
> TR/html4/strict.dtd">
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
> <title>test</title>
> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
> libs/jquery/1.3/jquery.min.js"></script>
> <script type="text/javascript">
> <!--
> $(function() {
>         function addtag() {
>
>                 $(this).before('<p><b class="close">x</b></p>');
>
>                 $(".close").click(function() {
>                         if (confirm('Are you sure you want to remove this?')){
>                                 $(this).remove();
>                         }
>                 });
>
>         }
> $(":button").click(addtag);});
>
> -->
> </script>
> <style type="text/css">
> <!--
> body { padding:30px; }
> div { width:30em; margin:0 auto; }
> p { margin:0 0 9px; }
> p b { text-decoration:underline; color:#06F; font-weight:400;
> cursor:pointer; }
> -->
> </style>
> </head>
> <body>
> <div>
>
> <input type="button" value="click">
>
> </div>
> </body>
> </html>

[jQuery] .html() causes null IE

Hi,
I am pretty new to jQuery and I am using the tablesorter plugin and I
am getting a .html() is null or not an object error within a custom
parser

the code

var ts = $.tablesorter;

// add parser through the tablesorter addParser method
ts.addParser({
id: "empnames",
is: function(s) {
return false;
},
format: function(s) {
// make an object of the string
var strobj = $($.trim(s));
return strobj.find("span").html().toLowerCase();
},
type: "text"
});

In that case is an object but as soon as I add .html() it returns null
in IE. It works fine in Safari and Firefox.
I am using jQuery 1.3.2 and tablesorter 2.0
I am trying to make it sort the text that's in a span. If anyone has a
better technique to do it it's also appreciated.

thanks

[jQuery] Re: generated content(PHP) into DIV?

On Apr 30, 12:23 pm, Tony <tony.mak...@ymail.com> wrote:
> Hello Everyone!
>
> I have 3 DIV's next to each other. I want that the first div is loaded
> over jquery with a php file which outputs an unordered list in html.
>
> When I click on a list item in the first DIV I want that jquery sends
> the parameters from the list to a second php file for making an
> unordered list which is loaded this time into the second DIV.
>
> The same should happen from the second DIV into the third DIV whith a
> third php file.
>
> All php files connect to a mysql database which has three tables
> (Place, House, Level). The tables have three columns(id, name,
> location). location is always linked to the next table's id (ex.
> "sesame street 1" has id 37 then tabel Place would have folowing
> entry: id=1 name=Stockholm location=37 )
>
> The purpose of this script is to navigate though houses in different
> places. The 3 DIV's contain following.
> DIV 1 = Place (ex. Stockholm, Berlin, Barcelona)
> DIV 2 = House (sesame street 1, sesame street 2, sesame street 3)
> DIV 3 = Level (Floor 1, Floor 2, Floor 3)
>
> I really tried all things in jquery from appendTo to $.ajax but I just
> dont get it working! The three divs are easy to create but getting the
> content dynamically into them seems quite impossible. Please help me,
> I tride really long to solve this problem but I just don't seem to get
> it, hope someone can help me :(

What does your code look like?

if you have a var placeContent = 'HTML string from ajax request';
$('#place').append( placeContent )
or
$('#place').html( placeContent )
or
$(placeContent).appendTo('#place')

should all work fine

[jQuery] Re: Conditional required fields

Thanks. I ended up using the classes add/remove style, and it works
well. However, a method that should be called on every page load is
not working properly. I am sure that it's being called (tested with
the console), but the removeValidators() method doesn't seem to work
properly.

http://content.constructioninst.org/corporate_renewal.html

On every page load, removeValidators will be called, which removes the
"required" and "email" validation classes found within the jQuery
object of the selector (first arg) if the caller's checkbox is
checked. The problem is if, for example, I fill out the first section
with its required fields, check the first box (which hides the bulk of
the form), choose "Check" for payment, and submit. If I go back, while
the hide/removeValidator method ("membersUnnecessary") is called and
does indicate that the checkbox is checked (the same sections are
hidden), I cannot re-submit the form: The validation classes are not
removed.

What can I do to fix this? I know that the code's a bit clumsy, but I
can explain any specific parts if needed.

Thanks,
Thomas

[jQuery] Confirmation alert fires multiple times with jQuery click

I add multiple items with each click and then I want to remove them
one by one by clicking.

All is ok, but if I add 2-3 items and the click the first one,
confirmation alert fires multiple times when i click Cancel.
The number of times depends on how many items goes after curent.

Please help to fix that :)

Code:
-----------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd
">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3/jquery.min.js
"></script>
<script type="text/javascript">
<!--
$(function() {
function addtag() {

$(this).before('<p><b class="close">x</b></p>');

$(".close").click(function() {
if (confirm('Are you sure you want to remove this?')){
$(this).remove();
}
});

}
$(":button").click(addtag);
});
-->
</script>
<style type="text/css">
<!--
body { padding:30px; }
div { width:30em; margin:0 auto; }
p { margin:0 0 9px; }
p b { text-decoration:underline; color:#06F; font-weight:400;
cursor:pointer; }
-->
</style>
</head>
<body>
<div>

<input type="button" value="click">

</div>
</body>
</html>

[jQuery] Re: cluetip jsonp and jquery doesn't play nice together

On Apr 30, 6:08 pm, postream <valentino.alu...@gmail.com> wrote:
> looking at thecluetipcode, this cant' be the problem
> this are lines 228 and 299 of the lastest version:
>
> var ajaxMergedSettings = $.extend(true, {}, opts.ajaxSettings,
> ajaxSettings);
>
> $.ajax(ajaxMergedSettings);
>
> the dataType is stored in opts.ajaxSettings
> so, every time an ajax call is performed, the dataType is set to the
> original one
>
> maybe Karl is right and you are using an old version...

Karl is right. I use 0.9.8 with jquery 1.2.

I'll try the newer version. The merge thingy really seems to fix this
problem.

Thanks.

[jQuery] Confirmation alert fires multiple times with jQuery click

I add multiple items with each click and then I want to remove them
one by one by clicking.

All is ok, but if I add 2-3 items and the click the first one,
confirmation alert fires multiple times when i click Cancel.
The number of times depends on how many items goes after curent.

Please help to fix that :)

Code:
-----------------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/
TR/html4/strict.dtd
">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/
libs/jquery/1.3/jquery.min.js
"></script>
<script type="text/javascript">
<!--
$(function() {
function addtag() {

$(this).before('<p><b class="close">x</b></p>');

$(".close").click(function() {
if (confirm('Are you sure you want to remove this?')){
$(this).remove();
}
});

}
$(":button").click(addtag);
});
-->
</script>
<style type="text/css">
<!--
body { padding:30px; }
div { width:30em; margin:0 auto; }
p { margin:0 0 9px; }
p b { text-decoration:underline; color:#06F; font-weight:400;
cursor:pointer; }
-->
</style>
</head>
<body>
<div>

<input type="button" value="click">

</div>
</body>
</html>

[jQuery] flexbox question

I'm evaluating Flexbox for a project:

http://www.fairwaytech.com/Technology/FlexBoxDemo.aspx

In example #1 there I can type in some chars and items with those chars
*inside* a result get highlighted (though only the first instance of the
found chars in any given item gets highlighted).

In all of the other demos the matching only occurs at the beginning of
the items.

Is it possible to have the *in the words* matching behavior happen (like
in example #1), but also have the list filtering behavior that the other
demos show? IE, if I have:

Guinea Pig
Pig
Iguana
Fox

and type in "i", I would like to have the dropdown display all matches
with "i" anywhere in them:

Guinea Pig
Pig
Iguana

The jquery autcomplete plugin will do it (type "i" in the E-Mail example):

http://jquery.bassistance.de/autocomplete/demo/

but there are some other features that Flexbox has that I'd like.

Thanks,
Jack

[jQuery] removing jQuery UI draggable revertDuration

I am using jQuery UI's Draggable plugin to allow the user to drag an
image from a box onto a google map to set a marker... the image they
were dragging then snaps back to the box it was originally inside of.

I'm running the code that updates the map using the draggable's
'dragend' event, but that callback doesn't seem to fire until the
draggable has finished reverting to its original position. I've set
the revertDuration to 0, 1, and other small numbers, but there seems
to be a minimum duration for its animation. Is there a way to remove
the animation entirely? The reason it matters is because the marker
is set using the latlong the mouse is hovering over at the time of the
callback, but the user can't be expected to hold their cursor exactly
still for the fraction of a second it takes for the draggable to revert.

Also if there's an easier way to do all of this, I'm all ears... I
glanced through the google map API and didn't see any way of dragging
something from outside the map into/onto the map.

[jQuery] Re: How to reduce this code by chain them up?

Ah.. okay. so it's .html() that's messing me up.

Thanks Ricardo. My original way of querying the templateTable by
passing itself as a "context" was awkward, the way you did is much
more "fluent".

That helps me a lot not only in this particular example, but helped me
understand the chainability as well. I greatly appreciate your help!!

Thanks again.


On Apr 30, 1:01 pm, Ricardo <ricardob...@gmail.com> wrote:
> On Apr 30, 10:27 am, Liming <lmxudot...@gmail.com> wrote:
>
>
>
> > Hello,
>
> > I have a div ( id="rightheader")  and inside there is a table. The
> > following code replace all content of the table with empty space and
> > then remove the table header.
>
> > var $templateTable = $("div#rightheader").clone();
> > $("tbody > tr > td > div ", $templateTable).html("&nbsp");
> > $("thead",$templateTable).remove();
>
> > I feel it might be unnecessary, but I can't figure out how to chain up
> > the statements.
>
> > I tried
>
> > var $templateTable = $("div#rightheader")
> >                                  .clone()
> >                                 .("tbody > tr > td > div ").html("&nbsp")
> >                                 .("thead").remove();
>
> > Got an error
>
> > then tried
>
> >         var $templateTable = $("div#rightheader")
> >                                                                  .clone()
> >                                                                  .find("tbody > tr > td > div ").html("&nbsp")
> >                                                                  .find("thead").remove();
>
> > but that just doesn't produce anything.
>
> > Sorry, I'm a real beginner on JQuery, any pointer is greatly
> > appreciate it.
>
> > Thanks
>
> the html() method doesn't return an object, so it has to be last:
>
> $("div#rightheader").clone()
>     .find("thead").remove().end()
>     .find("tbody > tr > td > div ").html("&nbsp");
>
> In this case I'd say chaining makes it more confusing, as you're
> copying/destroying elements on the way, not just traversing it. It's
> just a line shorter than this, which will be much clearer as I assume
> you're further modifying $templateTabe later:
>
> var $templateTable = $("div#rightheader").clone();
>
> $templateTable
>     .find("thead").remove().end()
>     .find("tbody > tr > td > div ").html("&nbsp");

[jQuery] Re: jQuery/JS/canvas/PHP remotely *shared* whiteboard

The version in the zip file now works (though no doubt could be
improved):

http://mynichecomputing.org/roughDrawKit.zip


On Apr 30, 9:20 am, lorlarz <lorl...@gmail.com> wrote:
> Oh, please email me at lorlarz at gmail.com if you
> get it working (or make it work better)
>
> On Apr 30, 9:19 am, lorlarz <lorl...@gmail.com> wrote:
>
>
>
> > A remotely shared white board, using regular JavaScript,
> > jQuery, the canvas element and PHP.
>
> > I hope I (or someone else) can get this thing working.
> > The new 8:25 a.m. (US CST) version in
>
> >http://mynichecomputing.org/roughDrawKit.zip
>
> > should work -- though I still have not seen it work, perhaps
> > due to a caching problem.- Hide quoted text -
>
> - Show quoted text -

[jQuery] Media Plugin (Malsup)

First off this media plugin is awesome and has saved me a lot of time,
thanks for all your work in developing this!

Now to the issue. I am sure you have come across this before where
you have 5-10 players on a page and you click the first player to
listen and then about halfway through you click on another player to
listen to a new song and boom your ears start exploding from the
mashing of rhythms! Is there a way to only "enable" one player at a
time, or some way to stop all the other players when you click play on
one?

I am using the latest JW player (4.3). Like I said, all is well this
would just be the icing on the cake :)

Thanks!
-David

[jQuery] Re: problem with closing all found divs

On Apr 30, 12:19 pm, heohni <heidi.anselstet...@consultingteam.de>
wrote:
> Hi,
>
> my source looks like this:
> (...)
> For some reason, the first table row stays always open... the second
> (and all following) are closed.
> What I do wrong? Is there a better way? I decided for this way, as I
> don't Know the div names, as they get filled by database id's.
>
> Thanks for help!
>
> Heidi

That HTML is not very inviting to read with all the line breaks. Try
putting it to work at jsbin.com or post at pastebin.org, that way it's
easier for someone to spot the issue.

cheers
-- ricardo

[jQuery] Re: form submit during getJSON

The malsup link. I should say Firefox displays a 'site unavailable'
page. Although I was directed the URL, it's apparently offline at the
moment.

On Apr 30, 12:44 pm, András Csányi <sayusi.a...@gmail.com> wrote:
> 2009/4/30 donb <falconwatc...@comcast.net>:
>
>
>
> > Whoa!  That link sents me to a 'spyware-files.info' website!!!
>
> Which link? What I'm suggested or my blogs link? Both working for me.
>
> --
> - -
> --  Csanyi Andras  --http://sayusi.hu-- Sayusi Ando
> --  "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell

[jQuery] Re: How to reduce this code by chain them up?

On Apr 30, 10:27 am, Liming <lmxudot...@gmail.com> wrote:
> Hello,
>
> I have a div ( id="rightheader")  and inside there is a table. The
> following code replace all content of the table with empty space and
> then remove the table header.
>
> var $templateTable = $("div#rightheader").clone();
> $("tbody > tr > td > div ", $templateTable).html("&nbsp");
> $("thead",$templateTable).remove();
>
> I feel it might be unnecessary, but I can't figure out how to chain up
> the statements.
>
> I tried
>
> var $templateTable = $("div#rightheader")
>                                  .clone()
>                                 .("tbody > tr > td > div ").html("&nbsp")
>                                 .("thead").remove();
>
> Got an error
>
> then tried
>
>         var $templateTable = $("div#rightheader")
>                                                                  .clone()
>                                                                  .find("tbody > tr > td > div ").html("&nbsp")
>                                                                  .find("thead").remove();
>
> but that just doesn't produce anything.
>
> Sorry, I'm a real beginner on JQuery, any pointer is greatly
> appreciate it.
>
> Thanks

the html() method doesn't return an object, so it has to be last:

$("div#rightheader").clone()
.find("thead").remove().end()
.find("tbody > tr > td > div ").html("&nbsp");

In this case I'd say chaining makes it more confusing, as you're
copying/destroying elements on the way, not just traversing it. It's
just a line shorter than this, which will be much clearer as I assume
you're further modifying $templateTabe later:

var $templateTable = $("div#rightheader").clone();

$templateTable
.find("thead").remove().end()
.find("tbody > tr > td > div ").html("&nbsp");

[jQuery] Re: jQuery barcode

What I meant is, is this solely for generating barcodes for printing?
Or is someone going to laser scan an LCD screen?

On Apr 29, 2:07 pm, Antonello Pasella <antonello.pase...@gmail.com>
wrote:
> On 29 Apr, 18:28, Ricardo <ricardob...@gmail.com> wrote:
>
> > Does this have any use case besides printing? If not, what's the point
> > in making it a jQuery plugin? (just curious).
>
> I wrote a javascript plugin (now with jQuery, maybe indipendent in the
> future) because in some cases a client generated barcode wolud be
> useful.
> No server side language dependencies (all by javascript) and no extra
> HTTP request for few bytes (network latency + brandwidth usage)
>
> I ran into a page with 3000 barcodes to be embedded and the 3000 HTTP
> requests blocks my server (100% CPU, all 255 threads working) for 240
> seconds. Using my plugin I drew them in 20 seconds.
>
> A courious aspect: FF3 is 10x slower than Chrome. I'll post in the FF
> ml for comments :D
>
> Bye

[jQuery] Re: form submit during getJSON

2009/4/30 donb <falconwatcher@comcast.net>:
>
> Whoa!  That link sents me to a 'spyware-files.info' website!!!

Which link? What I'm suggested or my blogs link? Both working for me.

--
- -
-- Csanyi Andras -- http://sayusi.hu -- Sayusi Ando
-- "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell

[jQuery] Re: form submit during getJSON

Whoa! That link sents me to a 'spyware-files.info' website!!!

On Apr 30, 12:30 pm, András Csányi <sayusi.a...@gmail.com> wrote:
> 2009/4/30 Ben <BHoipkem...@gmail.com>:
>
>
>
> > I am having trouble submitting a form by clicking on a button "<input
> > type='submit' />" while I am waiting for the callback of the $.getJSON
> > function to fire.
>
> > Is there a way to allow the form to submit even if the callback is
> > never called?
>
> Have you tried this?http://malsup.com/jquery/form/
>
> András
>
> --
> - -
> --  Csanyi Andras  --http://sayusi.hu-- Sayusi Ando
> --  "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell

[jQuery] Re: form submit during getJSON

2009/4/30 Ben <BHoipkemier@gmail.com>:
>
> I am having trouble submitting a form by clicking on a button "<input
> type='submit' />" while I am waiting for the callback of the $.getJSON
> function to fire.
>
> Is there a way to allow the form to submit even if the callback is
> never called?

Have you tried this?
http://malsup.com/jquery/form/

András

--
- -
-- Csanyi Andras -- http://sayusi.hu -- Sayusi Ando
-- "Bízzál Istenben és tartsd szárazon a puskaport!".-- Cromwell

[jQuery] Re: cluetip jsonp and jquery doesn't play nice together

looking at the cluetip code, this cant' be the problem
this are lines 228 and 299 of the lastest version:

var ajaxMergedSettings = $.extend(true, {}, opts.ajaxSettings,
ajaxSettings);

$.ajax(ajaxMergedSettings);

the dataType is stored in opts.ajaxSettings
so, every time an ajax call is performed, the dataType is set to the
original one

maybe Karl is right and you are using an old version...

_Valentino


On 30 Apr, 17:03, Karl Swedberg <k...@englishrules.com> wrote:
> If I'm understanding you correctly, the only way I can think of to get  
> around this (off the top of my head) is to include the metadata plugin  
> and set the datatype directly in the html.
>
> http://docs.jquery.com/Plugins/Metadata/metadata
>
> something like this (incomplete/untested):
>
> <a href="foo" class={ajaxSettings: {datatype: 'jsonp'}}">some text</a>
>
> Also, make sure you're using the latest version of the clueTip plugin  
> from Github:
>
> https://github.com/kswedberg/jquery-cluetip/tree/master
>
> --Karl
>
> ____________
> Karl Swedbergwww.englishrules.comwww.learningjquery.com
>
> On Apr 30, 2009, at 6:56 AM, cluetip user wrote:
>
>
>
> > Hi,
>
> > I wanted to use cluetip and jsonp with jquery (1.2.5, but apparently
> > the issue is also present in jquery 1.3).
>
> > I wanted to add a cluetip popup for a bunch of links like this:
>
> >  $("a[cluetip]").cluetip({'sticky': true,
> >    ajaxSettings: { dataType: 'jsonp'},
> >              ....});
>
> > This works very well for the first link which is hovered, but fails to
> > work with further links.
>
> > The problem is jquery overrides the jsonp dataType with "script":
>
> > // We need to make sure
> > // that a JSONP style response is executed properly
> > s.dataType = "script";
>
> > Since the ajaxSettings dictionary in the cluetip call is shared by all
> > links, the first activation overrides the dataType for all of them,
> > and no further jsonp calls will be made, because the data type is not
> > jsonp anymore.
>
> > Is it a bug? I didn't see a way to invoke cluetip for the links one by
> > one, so that I can pass in a different dictionary instance for each of
> > them.
>
> > Can you suggest me a workaround? Thanks.

comp.lang.c++ - 25 new messages in 10 topics - digest

comp.lang.c++
http://groups.google.com/group/comp.lang.c++?hl=en

comp.lang.c++@googlegroups.com

Today's topics:

* addr to long - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/8c07d55c00e3053e?hl=en
* Delegates ,smart pointers and GUI - 6 messages, 4 authors
http://groups.google.com/group/comp.lang.c++/t/f5ef7b3e0a822708?hl=en
* std::abs ambiguity - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/ecfa9110b83039de?hl=en
* Window C++ Compiler - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/c70a2463dd900f3e?hl=en
* STL map+vector compilation failure issue - 6 messages, 5 authors
http://groups.google.com/group/comp.lang.c++/t/492e3b6157308868?hl=en
* ostream::write - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/a8929aac2301abf6?hl=en
* function implementation with stack vs heap allocation - 4 messages, 3
authors
http://groups.google.com/group/comp.lang.c++/t/05f7537165e6c5f4?hl=en
* >>>>Just Do It<<<<< NIKE sneakers wholesale free shipping paypal payment - 1
messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/d54356e70fec3396?hl=en
* Implicit conversion and method call - 1 messages, 1 author
http://groups.google.com/group/comp.lang.c++/t/1af613b157b9cd86?hl=en
* contiguous in memory - 2 messages, 2 authors
http://groups.google.com/group/comp.lang.c++/t/a5e84c1f1717e18c?hl=en

==============================================================================
TOPIC: addr to long
http://groups.google.com/group/comp.lang.c++/t/8c07d55c00e3053e?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 30 2009 4:05 am
From: Juha Nieminen


Krzysztof Poc wrote:
> Hello
>
> How can I convert ptr (of any type) to long.
> Can I do that as follows:
>
> long addr = reinterpret_cast<long>(&objOfAnyType);
>
> Is it correct for all platforms 32/64 bit ?

The standard does not guarantee that sizeof(long) equals sizeof(void*)
(and in fact, in MSVC long is 32-bit and void* is 64-bit when compiling
a 64-bit binary).

If you want a signed integral which is as large as a pointer, use the
ptrdiff_t standard type. (If you want it unsigned, use size_t.)

==============================================================================
TOPIC: Delegates ,smart pointers and GUI
http://groups.google.com/group/comp.lang.c++/t/f5ef7b3e0a822708?hl=en
==============================================================================

== 1 of 6 ==
Date: Thurs, Apr 30 2009 4:53 am
From: KjellKod


Something very similar as 'delegates' are in fact commonly used in C++
(GUI) frameworks.
Check out signals by
Boost (http://www.boost.org/doc/libs/1_38_0/doc/html/signals.html)
and Qt (http://doc.trolltech.com/4.5/signalsandslots.html)

Other not so famous examples but still open source examples of signals
are also available
(KSignals http://kjell.hedstrom.googlepages.com/signalandslots and
SigSlot http://sigslot.sourceforge.net/)

Using signals you have type safe function callback (i.e. similar to
delegate) encapsuled
in signals (and slots) making it easy to use for anyone without
requiring too much information
about how they work in detail.


== 2 of 6 ==
Date: Thurs, Apr 30 2009 6:16 am
From: Phlip


KjellKod wrote:

> Something very similar as 'delegates' are in fact commonly used in C++
> (GUI) frameworks.
> Check out signals by
> Boost (http://www.boost.org/doc/libs/1_38_0/doc/html/signals.html)
> and Qt (http://doc.trolltech.com/4.5/signalsandslots.html)

Signals and slots are not "in C++". Trolltech provides them by adding two new
keywords to C++. You can't do what they did without their language extension.

Oh, and the keywords provide dynamic typing and a kind of closure. Go figure!

--
Phlip


== 3 of 6 ==
Date: Thurs, Apr 30 2009 7:07 am
From: SG


On 30 Apr., 15:16, Phlip <phlip2...@gmail.com> wrote:
> KjellKod wrote:
> > Something very similar as 'delegates' are in fact commonly used in C++
> > (GUI) frameworks.
> > Check out signals by
> > Boost (http://www.boost.org/doc/libs/1_38_0/doc/html/signals.html)
> > and Qt (http://doc.trolltech.com/4.5/signalsandslots.html)
>
> Signals and slots are not "in C++". Trolltech provides them by adding two new
> keywords to C++. You can't do what they did without their language extension.

It's my understanding that a similar feature can be more or less
emulated with C++ language features. IIRC, Trolltech didn't do it that
way because they started development early and C++ compilers were not
very mature w.r.t. templates back then.

I'm not much of a GUI programmer but I did check out gtkmm a little
bit. They also have signals and slots but they're implemented as a C++
library.

The only experience with GUI programming I have is with Java/Swing.
The talk about closures reminded of the need to write something like

SwingUtilities.invokeLater(new Runnable(){
public void run() {
// do something
}
});

in Java if you're in another thread and want an action to be performed
in Swing's event loop thread. In C++0x you'd be able to do something
similar:

// called from event loop thread as result of
// a user action, for example
void foo::on_click() {
MyGuiFramework::perform_async(
[] { calculations(); }, // async job
[this] { this->ready(); } // when done
);
}

// called from event loop thread
// (after calculations are complete)
void foo::ready() {
// ...
}

where most of the magic is hidden behind the fictional
"MyGuiFramework::perform_async". This is just one idea that comes to
mind. ;-)


Cheers!
SG


== 4 of 6 ==
Date: Thurs, Apr 30 2009 8:03 am
From: boltar2003@yahoo.co.uk


On Thu, 30 Apr 2009 07:07:37 -0700 (PDT)
SG <s.gesemann@gmail.com> wrote:
>in Java if you're in another thread and want an action to be performed
>in Swing's event loop thread. In C++0x you'd be able to do something
>similar:

I don't understand why you'd want threading built into the core C++ language.
Threads are an OS facility with many different attributes across many
different systems. Is the language going to support every single one of
these including low level tweaking or will it just have a common subset
making it useless for anyone who needs something a bit more specialised?

And if its going to support threading natively as opposed to being in
a system library why stop at threads - why not add multiprocess while
they're at it? Perhaps finally Windows could finally get a half decent
implementation of fork()!

B2003

== 5 of 6 ==
Date: Thurs, Apr 30 2009 8:17 am
From: SG


On 30 Apr., 17:03, boltar2...@yahoo.co.uk wrote:
> On Thu, 30 Apr 2009 07:07:37 -0700 (PDT)
>
> SG <s.gesem...@gmail.com> wrote:
> >in Java if you're in another thread and want an action to be performed
> >in Swing's event loop thread.  In C++0x you'd be able to do something
> >similar:
>
> I don't understand why you'd want threading built into the core C++ language.

I suggested nothing of that kind. MyGuiFramework::perform_async is a
fictional function that just "magically" works. So, it *could* use
some form of OS specific threading library.

If you're working with some GUI framework (typical event loop thingy)
and want to stay responsive while loading a file or computing
something, you *have* to use threads. I'm sure that most of the GUI
toolkits that are available for C++ come with some sort of threading
support and synchronization primitives just for that reason.

By the way, C++0x will support threading directly.

Cheers!
SG


== 6 of 6 ==
Date: Thurs, Apr 30 2009 8:52 am
From: boltar2003@yahoo.co.uk


On Thu, 30 Apr 2009 08:17:20 -0700 (PDT)
SG <s.gesemann@gmail.com> wrote:
>By the way, C++0x will support threading directly.

Thats what I was talking about.

B2003


==============================================================================
TOPIC: std::abs ambiguity
http://groups.google.com/group/comp.lang.c++/t/ecfa9110b83039de?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 30 2009 5:19 am
From: "Christopher Dearlove"


"Alf P. Steinbach" <alfps@start.no> wrote in message
news:gtbrpn$1rt$1@news.eternal-september.org...
> You're talking about an implementation conforming to C++98?

I was talking about de facto C++98 and de jure C++0X according to James's
third model.

> Assuming that works nicely, and I can't see why not, it isn't difficult.
> As is oft stated, the solution to every computer science problem is
> indirection. :-)

There's enough detail there for me to see how to do it. Why anyone
would want to do it (as you are deliberately setting out to follow that
model rather than the other two) is less clear, though I suppose it may
relate to being able to compile more C programs written not aware of
C++ with a C++ compiler (those using abs in various ways for example).

Thanks.

==============================================================================
TOPIC: Window C++ Compiler
http://groups.google.com/group/comp.lang.c++/t/c70a2463dd900f3e?hl=en
==============================================================================

== 1 of 2 ==
Date: Thurs, Apr 30 2009 5:50 am
From: Lionel B


On Thu, 30 Apr 2009 04:03:19 -0700, James Kanze wrote:

> On Apr 29, 5:43 pm, Noah Roberts <n...@nowhere.com> wrote:
>> red floyd wrote:
>> > cplusplusquest...@gmail.com wrote:
>> >> I'm using Linux C++ compiler. Is there anyone recommend me which
>> >> free Window C++ compiler is good? Thanks!
>
>> > G++ has a Windows port as well. Google for MinGW. If you'd prefer a
>> > full Linux style environment, google for Cygwin.
>
> Which you can also use with VC++.
>
>> You don't need Cygwin to get the Linux unix shell and tools. The people
>> who make MinGW also make Msys. You only need Cygwin if you need unix
>> compatibility.
>
> Unix compatibility in what way. My experience with this is that Cygwin
> and MSys don't integrate very well with Windows; it's like having two
> different systems, in different windows, and it's very awkward to use
> anything but the Cygwin/MSys tools from one of their shells.

Agreed. But is it fair to expect Cygwin to be "compatible" in the sense
of integrating seamlessly with Windows? Ultimately Windows != Unix and
perhaps the best we should expect of Cygwin is as a (partially) self-
contained Linux-alike environment running under the Windows OS with an
interface - albeit somewhat clunky - to Windows resources. Perhaps it
could be done better...

[In a former job I did once find Cygwin something of a life-saver. Coming
from a Unix background I became increasingly aware and frustrated at how
much easier it would be to get the work done productively in a Unix
environment. I managed to get away with installing Cygwin under the (very
MS-entrenched) sysadmin's radar and, on the whole, it delivered - albeit
not quite seamlessly.]

> MSys is
> the worst here, since it doesn't allow passing command line arguments
> beginning with / to the program you're invoking (and not all Windows
> programs are as open as VC++, and accept - to indicate an option, rather
> than /); output from the MSys tools also uses the Unix line separator,
> which can cause problems with some Windows tools. (And of course, if you
> don't need any of the native Windows tools, you can just install Linux,
> and get even better integration of the Unix toolkit).

Sure - but I don't believe MSYS purports to be much more than a minimal
implementation of a minimal environment enabling a minimal GNU/GCC
development toolchain. I agree that it is, even in this respect, flawed.

[...]

--
Lionel B


== 2 of 2 ==
Date: Thurs, Apr 30 2009 6:41 am
From: red floyd


James Kanze wrote:
> On Apr 29, 5:43 pm, Noah Roberts <n...@nowhere.com> wrote:
>> red floyd wrote:
>>> cplusplusquest...@gmail.com wrote:
>>>> I'm using Linux C++ compiler. Is there anyone recommend me which free
>>>> Window C++ compiler is good? Thanks!
>
>>> G++ has a Windows port as well. Google for MinGW. If you'd
>>> prefer a full Linux style environment, google for Cygwin.
>
> Which you can also use with VC++.
>

I mentioned it because OP had specified he was using Linux already.

==============================================================================
TOPIC: STL map+vector compilation failure issue
http://groups.google.com/group/comp.lang.c++/t/492e3b6157308868?hl=en
==============================================================================

== 1 of 6 ==
Date: Thurs, Apr 30 2009 6:02 am
From: boltar2003@yahoo.co.uk


Hi

I'm probably making some idiot mistake but can someone tell me why the
following fails to compile with a no matching function call error under
gcc:

map<int,vector<pair<int,int> > > m;
m[123] = vector<pair<int,int> >(pair<int,int>(2,3));

However a simple integer vector in the map compiles just fine:

map<int,vector<int> > m2;
m2[123] = vector<int>(2);

I can easily work around the issue but I'd like to know what I'm doing
wrong anyway. Thanks for any help

B2003


== 2 of 6 ==
Date: Thurs, Apr 30 2009 6:13 am
From: "Thomas J. Gritzan"


boltar2003@yahoo.co.uk schrieb:
> Hi
>
> I'm probably making some idiot mistake but can someone tell me why the
> following fails to compile with a no matching function call error under
> gcc:
>
> map<int,vector<pair<int,int> > > m;
> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));

Because there's no constructor in vector that takes a pair?

Try this:

m[123] = vector<pair<int,int> >( 42, make_pair(2,3) );

This constructs a vector with 42 elements, each copy constructed from a
pair<int,int>.

The make_pair function allows to omit the template parameters of the pair.

--
Thomas


== 3 of 6 ==
Date: Thurs, Apr 30 2009 6:17 am
From: boltar2003@yahoo.co.uk


On Thu, 30 Apr 2009 15:13:28 +0200
"Thomas J. Gritzan" <phygon_antispam@gmx.de> wrote:
>
>
>boltar2003@yahoo.co.uk schrieb:
>> Hi
>>
>> I'm probably making some idiot mistake but can someone tell me why the
>> following fails to compile with a no matching function call error under
>> gcc:
>>
>> map<int,vector<pair<int,int> > > m;
>> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>
>Because there's no constructor in vector that takes a pair?

But why would it need a specific pair constructor anyway? Why doesn't it just
use the generic templated constructor?

B2003

== 4 of 6 ==
Date: Thurs, Apr 30 2009 6:45 am
From: red floyd


boltar2003@yahoo.co.uk wrote:
> Hi
>
> I'm probably making some idiot mistake but can someone tell me why the
> following fails to compile with a no matching function call error under
> gcc:
>
> map<int,vector<pair<int,int> > > m;
> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>
> However a simple integer vector in the map compiles just fine:
>
> map<int,vector<int> > m2;
> m2[123] = vector<int>(2);
>

Because the int parameter to the vector constructor is not a member, but
a *COUNT*.

m2[123] = vector<int>(2);

Creates a vector with 2 default constructed ints.

Try reading the documentation on vector.


== 5 of 6 ==
Date: Thurs, Apr 30 2009 6:46 am
From: Vaclav Haisman


boltar2003@yahoo.co.uk wrote, On 30.4.2009 15:17:
> On Thu, 30 Apr 2009 15:13:28 +0200
> "Thomas J. Gritzan" <phygon_antispam@gmx.de> wrote:
>>
>> boltar2003@yahoo.co.uk schrieb:
>>> Hi
>>>
>>> I'm probably making some idiot mistake but can someone tell me why the
>>> following fails to compile with a no matching function call error under
>>> gcc:
>>>
>>> map<int,vector<pair<int,int> > > m;
>>> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>> Because there's no constructor in vector that takes a pair?
>
> But why would it need a specific pair constructor anyway? Why doesn't it just
> use the generic templated constructor?
std::vector has several ctors but none that would take value of type T. See
e.g. <http://stdcxx.apache.org/doc/stdlibref/vector.html#idx1305>.

--
VH


== 6 of 6 ==
Date: Thurs, Apr 30 2009 7:01 am
From: Pete Becker


boltar2003@yahoo.co.uk wrote:
> On Thu, 30 Apr 2009 15:13:28 +0200
> "Thomas J. Gritzan" <phygon_antispam@gmx.de> wrote:
>>
>> boltar2003@yahoo.co.uk schrieb:
>>> Hi
>>>
>>> I'm probably making some idiot mistake but can someone tell me why the
>>> following fails to compile with a no matching function call error under
>>> gcc:
>>>
>>> map<int,vector<pair<int,int> > > m;
>>> m[123] = vector<pair<int,int> >(pair<int,int>(2,3));
>> Because there's no constructor in vector that takes a pair?
>
> But why would it need a specific pair constructor anyway? Why doesn't it just
> use the generic templated constructor?
>

Which generic templated constructor do you want it to use? Hint: don't
guess; look at the specification for vector.

--
Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com) Author of
"The Standard C++ Library Extensions: a Tutorial and Reference"
(www.petebecker.com/tr1book)

==============================================================================
TOPIC: ostream::write
http://groups.google.com/group/comp.lang.c++/t/a8929aac2301abf6?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 30 2009 6:43 am
From: Vaclav Haisman


Ralf Goertz wrote, On 30.4.2009 11:12:
> Hi,
>
> what is the reason that
>
> ostream& ostream::write ( const char* s , streamsize n );
>
> is not defined as
>
> ostream& ostream::write ( const void* p , streamsize n );
>
> like its C-counterpart?
I suspect two reasons: 1st, char is what streams are about, and 2nd, aliasing
issues. Maybe even 3rd, type safety. The former forces you to stop and think
and add the cast to char* while the latter accepts any pointer.

--
VH

==============================================================================
TOPIC: function implementation with stack vs heap allocation
http://groups.google.com/group/comp.lang.c++/t/05f7537165e6c5f4?hl=en
==============================================================================

== 1 of 4 ==
Date: Thurs, Apr 30 2009 7:21 am
From: "Hicham Mouline"


Hello,

I have a function f that is called a large number of times
my current implementation is

bool f( iterator begin, iterator end ... )
{
const size_t n =end - begin;
....
....
boost::scoped_array<some_type> a( new some_type[n] );
...
...
return true;
}

However I tested the same implementation with a on-stack allocation

bool f( iterator begin, iterator end ... )
{
const size_t n =end - begin;
....
....
const size_t maxN = 64;
if (n>64)
{
return false;
}
some_type a[maxN ]; // or maybe boost::array< some_type, maxN > a;
...
...
return true;
}

Given the size of my problem, I am mostly in implementation 2, but sometimes
it may be over 64 and therefore would like to use dynamic allocation.

How can I not duplicate the code ? I can't see it.

some_type* a;
if (n>64){
a = new ...
}
else{
a = ???
}


regards,

is this the kind of things STL allocators do? should I template this
function with an allocator?


== 2 of 4 ==
Date: Thurs, Apr 30 2009 8:02 am
From: SG


On 30 Apr., 16:21, "Hicham Mouline" <hic...@mouline.org> wrote:
> Hello,
>
> I have a function f that is called a large number of times
> my current implementation is
>
> bool f(   iterator begin, iterator end ... )
> {
> const size_t n =end - begin;
>  ....
>  ....
>  boost::scoped_array<some_type> a( new some_type[n] );
>  ...
> ...
> return true;
> }
>
> However I tested the same implementation with a on-stack allocation
> [...]
> Given the size of my problem, I am mostly in implementation 2, but sometimes
> it may be over 64 and therefore would like to use dynamic allocation.
>
> How can I not duplicate the code ? I can't see it.

The simple solution would be to separate allocation and the "real
work":

bool backend(iterator begin, iterator end, some_type* p, ..... )
{
// real work with p
}

bool f(iterator begin, iterator end, ..... )
{
const size_t n =end - begin;
if (n<=64) {
some_type arr[64];
return backend(begin,end,arr, ..... );
} else {
vector<some_type> vec (n);
return backend(begin,end,&vec[0], ..... );
}
}

Cheers!
SG


== 3 of 4 ==
Date: Thurs, Apr 30 2009 8:17 am
From: "Hicham Mouline"

"SG" <s.gesemann@gmail.com> wrote in message
news:bf579ef7-eb1e-4878-9683-69ea71c43680@q33g2000pra.googlegroups.com...
On 30 Apr., 16:21, "Hicham Mouline" <hic...@mouline.org> wrote:
> Hello,
>
> I have a function f that is called a large number of times
> my current implementation is
>
> bool f( iterator begin, iterator end ... )
> {
> const size_t n =end - begin;
> ....
> ....
> boost::scoped_array<some_type> a( new some_type[n] );
> ...
> ...
> return true;
> }
>
> However I tested the same implementation with a on-stack allocation
> [...]
> Given the size of my problem, I am mostly in implementation 2, but
> sometimes
> it may be over 64 and therefore would like to use dynamic allocation.
>
> How can I not duplicate the code ? I can't see it.

The simple solution would be to separate allocation and the "real
work":

bool backend(iterator begin, iterator end, some_type* p, ..... )
{
// real work with p
}

bool f(iterator begin, iterator end, ..... )
{
const size_t n =end - begin;
if (n<=64) {
some_type arr[64];
return backend(begin,end,arr, ..... );
} else {
vector<some_type> vec (n);
return backend(begin,end,&vec[0], ..... );
}
}

Cheers!
SG
-------------------
I'd need to make backend inline...
otherwise I may lose the benefit gained from having the array on the stack,
no?


== 4 of 4 ==
Date: Thurs, Apr 30 2009 8:59 am
From: pjb@informatimago.com (Pascal J. Bourguignon)


"Hicham Mouline" <hicham@mouline.org> writes:

> The simple solution would be to separate allocation and the "real
> work":
>
> bool backend(iterator begin, iterator end, some_type* p, ..... )
> {
> // real work with p
> }
>
> bool f(iterator begin, iterator end, ..... )
> {
> const size_t n =end - begin;
> if (n<=64) {
> some_type arr[64];
> return backend(begin,end,arr, ..... );
> } else {
> vector<some_type> vec (n);
> return backend(begin,end,&vec[0], ..... );
> }
> }
>
> Cheers!
> SG
> -------------------
> I'd need to make backend inline...
> otherwise I may lose the benefit gained from having the array on the stack,
> no?

Compile this function to assembler and see what it does. Short
answer: No, you won't lose anything. More, if you use a recent gcc,
you may get TCO so the return backend() is actually implemented with a
JMP instead of JSR/RET.

--
__Pascal Bourguignon__

==============================================================================
TOPIC: >>>>Just Do It<<<<< NIKE sneakers wholesale free shipping paypal
payment
http://groups.google.com/group/comp.lang.c++/t/d54356e70fec3396?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 30 2009 7:44 am
From: wholesale free shipping


Discount Nike air jordans (www.guoshitrade.com)
Discount Nike Air Max 90 Sneakers (www.guoshitrade.com)
Discount Nike Air Max 91 Supplier (www.guoshitrade.com)
Discount Nike Air Max 95 Shoes Supplier (www.guoshitrade.com)
Discount Nike Air Max 97 Trainers (www.guoshitrade.com)
Discount Nike Air Max 2003 Wholesale (www.guoshitrade.com)
Discount Nike Air Max 2004 Shoes Wholesale (www.guoshitrade.com)
Discount Nike Air Max 2005 Shop (www.guoshitrade.com)
Discount Nike Air Max 2006 Shoes Shop (www.guoshitrade.com)
Discount Nike Air Max 360 Catalogs (www.guoshitrade.com)
Discount Nike Air Max Ltd Shoes Catalogs (www.guoshitrade.com)
Discount Nike Air Max Tn Men's Shoes (www.guoshitrade.com)
Discount Nike Air Max Tn 2 Women's Shoes (www.guoshitrade.com)
Discount Nike Air Max Tn 3 Customize (www.guoshitrade.com)
Discount Nike Air Max Tn 4 Shoes Customize ( www.guoshitrade.com)
Discount Nike Air Max Tn 6 Supply (www.guoshitrade.com)
Discount Nike Shox NZ Shoes Supply (www.guoshitrade.com)
Discount Nike Shox OZ Sale (www.guoshitrade.com)
Discount Nike Shox TL Store (www.guoshitrade.com)
Discount Nike Shox TL 2 Shoes Store (www.guoshitrade.com)
Discount Nike Shox TL 3 Distributor (www.guoshitrade.com)
Discount Nike Shox Bmw Shoes Distributor (www.guoshitrade.com)
Discount Nike Shox Elite Shoes Manufacturer (www.guoshitrade.com)
Discount Nike Shox Monster Manufacturer (www.guoshitrade.com)
Discount Nike Shox R4 Running Shoes (www.guoshitrade.com)
Discount Nike Shox R5 Mens Shoes (www.guoshitrade.com)
Discount Nike Shox Ride Womens Shoes (www.guoshitrade.com)
Discount Nike Shox Rival Shoes Wholesaler (www.guoshitrade.com)
Discount Nike Shox Energia Wholesaler (www.guoshitrade.com)
Discount Nike Shox LV Sneaker (www.guoshitrade.com)
Discount Nike Shox Turbo Suppliers (www.guoshitrade.com)
Discount Nike Shox Classic Shoes Suppliers (www.guoshitrade.com)
Discount Nike Shox Dendara Trainer (www.guoshitrade.com)
Discount Nike Air Jordan 1 Seller (www.guoshitrade.com)
Discount Nike Air Jordan 2 Shoes Seller (www.guoshitrade.com)
Discount Nike Air Jordan 3 Collection (www.guoshitrade.com)
Discount Nike Air Jordan 4 Shoes Collection (www.guoshitrade.com)
Discount Nike Air Jordan 5 Chaussure Shoes (www.guoshitrade.com)
Discount Nike Air Jordan 6 Catalog (www.guoshitrade.com)
Discount Nike Air Jordan 7 Shoes Catalog (www.guoshitrade.com)
Discount Nike Air Jordan 8 Customized (www.guoshitrade.com)
Discount Nike Air Jordan 9 Shoes Customized (www.guoshitrade.com)
Discount Nike Air Jordan 10 Wholesalers (www.guoshitrade.com)
Discount Nike Jordan 11 Shoes Wholesalers (www.guoshitrade.com)
Discount Nike Air Jordan 12 Factory (www.guoshitrade.com)
Discount Nike Air Jordan 13 Shoes Factory (www.guoshitrade.com)
Discount Nike Air Jordan 14 Shoes Sell (www.guoshitrade.com)
Discount Nike Air Jordan 16 Exporter (www.guoshitrade.com)
Discount Nike Air Jordan 17 Shoes Exporter (www.guoshitrade.com)
Discount Nike Air Jordan 18 Offer (www.guoshitrade.com)
Discount Nike Air Jordan 19 Shoes Offer (www.guoshitrade.com)
Discount Nike Air Jordan 20 Manufacture (www.guoshitrade.com)
Discount Nike Jordan 21 Shoes Manufacture (www.guoshitrade.com)


More detail land, address:www.guoshitrade.com

==============================================================================
TOPIC: Implicit conversion and method call
http://groups.google.com/group/comp.lang.c++/t/1af613b157b9cd86?hl=en
==============================================================================

== 1 of 1 ==
Date: Thurs, Apr 30 2009 8:25 am
From: Victor Bazarov


Vladimir Jovic wrote:
> Victor Bazarov wrote:
>> GeeRay wrote:
>>> Hi all,
>>> how can I create a template class to decorate a type and use it as
>>> the type itself?
>>>
>>> For example:
>>>
>>> I want to do this:
>>>
>>> #include <iostream>
>>> class A
>>> {
>>> public:
>>> A(){};
>>> virtual ~A(){};
>>> void foo(){ std::cout << "foo" << std::endl;};
>>> };
>>>
>>>
>>> template<class T>
>>> class B
>>> {
>>> public:
>>> B(){};
>>> virtual ~B(){};
>>> operator T(){return instance;};
>>> private:
>>> T instance;
>>> };
>>>
>>>
>>>
>>> int main(int argn, char* argv[])
>>> {
>>> B<A> b();
>>
>> Drop the parentheses, otherwise you're declaring a function. My
>> answer assumes that the definition of 'b' is like this:
>>
>> B<A> b;
>>
>>> b.foo();
>>> }
>>>
>>>
>>> Is it possible?
>>
>> No. For the member function calls (like the . you use to access the
>> 'foo' member) the conversions are not considered. You can overload
>> the member access operator for pointers (pretending that your 'B'
>> class is a pointer), like so:
>>
>> template<class T> class B { ...
>>
>> T* operator->() { return &instance; }
>> };
>>
>> , then you could write something like
>>
>> B<A> b;
>> b->foo();
>>
>> which is not necessarily the best syntax, of course...
>
> Another happy solution:
> static_cast< A >(b).foo();

Or just

A(b).foo();

will probably work just as well. But the point is that the OP didn't
want to remember that 'A' was involved. So, your operator() solution is
a bit better in that respect.

> [..]

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask

==============================================================================
TOPIC: contiguous in memory
http://groups.google.com/group/comp.lang.c++/t/a5e84c1f1717e18c?hl=en
==============================================================================

== 1 of 2 ==
Date: Thurs, Apr 30 2009 8:33 am
From: "Hicham Mouline"


void f()
{
auto v1;
auto v2; // consecutive in source code
....
}

Are there any guarantees by c++ that the 2 auto variables are such that &v2
== &v1 + sizeof(v1) ? are they contiguous?

if not, my question becomes empirical here
1. under x86-64, is this always true?
2. under x86-64 msvc, is this always true?
3. under x86-64 g++4.x is this always true?

regards,


== 2 of 2 ==
Date: Thurs, Apr 30 2009 8:55 am
From: Victor Bazarov


Hicham Mouline wrote:
> void f()
> {
> auto v1;
> auto v2; // consecutive in source code

"auto" what? You don't have a type specified, and no initialisation to
derive the type from.

> ....
> }
>
> Are there any guarantees by c++ that the 2 auto variables are such that &v2
> == &v1 + sizeof(v1) ? are they contiguous?

No, of course not. Not to mention that the optimizer can omit placing
them in memory altogether.

>
> if not, my question becomes empirical here

A question cannot be empirical. An answer can be.

> 1. under x86-64, is this always true?

Not likely. Why would it differ from the general answer?

> 2. under x86-64 msvc, is this always true?

Ask in the msvc newsgroup.

> 3. under x86-64 g++4.x is this always true?

Ask in the gnu newsgroup.

V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask


==============================================================================

You received this message because you are subscribed to the Google Groups "comp.lang.c++"
group.

To post to this group, visit http://groups.google.com/group/comp.lang.c++?hl=en

To unsubscribe from this group, send email to comp.lang.c+++unsubscribe@googlegroups.com

To change the way you get mail from this group, visit:
http://groups.google.com/group/comp.lang.c++/subscribe?hl=en

To report abuse, send email explaining the problem to abuse@googlegroups.com

==============================================================================
Google Groups: http://groups.google.com/?hl=en