function

Jquery toggle function that doesn't return false?

Hi, Is it possible to stop the automatic preventDefault() from applying in a simple Jquery toggle function? $(".mydiv").toggle( function () { $(this).addClass("blue"); }, function () { $(this).removeClass("blue"); } ); The above prevents elements inside the div from responding normally to the click. I...

Handler invocation speed: Objective-C vs virtual functions

I heard that calling a handler (delegate, etc.) in Objective-C can be even faster than calling a virtual function in C++. Is it really correct? If so, how can that be? AFAIK, virtual functions are not that slow to call. At least, this is my understanding of what happens when a virtual function is called: Obtain the pointer to vtbl. De...

Returning char* in function

I have function: char *zap(char *ar) { char pie[100] = "INSERT INTO test (nazwa, liczba) VALUES ('nowy wpis', '"; char dru[] = "' )"; strcat(pie, ar); strcat(pie, dru); return pie; } and in main there is: printf("%s", zap( argv[1] ) ); When compiling I get the warning: test.c: In function ‘zap’: test.c:17: wa...

Default values of parametrs for own functions in jquery

Is it possible to set default values of parametrs for own functions in jquery? ...

Javascript, problem with binding an event to a div-tag

Hello, i am trying to bind an event to a dynamically created div. function GameField(playerNumber) { this.fields = new Array(); this.player = playerNumber; this.isPlayerActive = false; this.currentRound = 0; } GameField.prototype.InitField = function(fieldNumber) { var newField = document.createElement("div"); if (fieldNumber =...

Advice on my jQuery Ajax Function

So on my site, a user can post a comment on 2 things: a user's profile and an app. The code works fine in PHP but we decided to add Ajax to make it more stylish. The comment just fades into the page and works fine. I decided I wanted to make a function so that I wouldn't have to manage 2 (or more) blocks of codes in different files. Rig...

Concatenate javascript to a string/parameter in a function

I am using kottke.org's old JAH example to return some html to a div in a webpage. The code works fine if I use static text. However I need to get the value of a field to add to the string that is getting passed as the parameter to the function. var xmlhttp=false; /*@cc_on @*/ /*@if (@_jscript_version >= 5) try { xmlhttp = new ActiveX...

How to explain method calls?

Hi, let's consider a small method: int MyFunction(string foo, int bar) { ... } and some calls: MyFunction("",0) int x = MyFunction(foo1,bar1) How would you explain this to a non-technical persons? Has anybody a nice metaphor? I tried to explain method calling (or function application) several times, but I failed. Seems I can't ...

Jquery with call back functions

Hi, i have one problem with the Jquery callback functions, here is the link: http://saveenergy.metropolia.fi/views/pihkapuisto/ as you can see, the first page works fine. but all the others are not fine. they always right side and the size is too small. anyone knows how to change the position and size, make it looks like the first one? t...

AS3 - Can I have access to the object (or function) who call me?

I've asked this same question with Python. Now I like to know if this can be done in AS3. If I have something like this: package { public class SomeClass { private function A():void { C() } private function B():void { C() } private function C():void { // who is the caller, A or B ??...

mysql max function usage

the table videos has the folowing feels id,average,name how can i write the query, to select the name of video, which have the max average!!! i can do that vith two queries, by selecting the max(avege) from the table, and then find out the name, where ihe average equal to max!!! but i want to do that in one query!!! help me please!!! ...

How to combine these two JavaScript functions?

var curtext = "View large image"; function changeSrc() { if (curtext == "View large image") { document.getElementById("boldStuff").innerHTML = "View small image"; curtext="View small image"; } else { document.getElementById("boldStuff").innerHTML = "View large image"; curtext = "View large image"; ...

Creating a function reference that has value parameters not references

I'm not sure exactly how to describe what I want. I want to define a function with the parameters being a local VALUE not a reference. say I have list of objects I want to create for(i = 0; i < 10; i++){ var div = document.createElement("div"); div.onclick = function(){alert(i);}; document.appendChild(div); } Now I believe in ...

Deleting object in function

Let's say I have created two objects from class foo and now want to combine the two. How, if at all possible, can I accomplish that within a function like this: def combine(first, second): first.value += second.value del second #this doesn't work, though first.value *does* get changed instead of doing something like def combi...

is it better to make function small in javascript?

Recently I read a book(CleanCode) in this book, FUNCTION SHOULD DO ONE THING. THEY SHOULD DO IT WELL. THEY SHOULD DO IT ONLY. and function should be small. But I think the function in javascript. If I split big function to small things, the code is getting longer and It takes more time to render. Is it better to make...

Get a JQuery function to execute after and independently of onLoad

Is is possible to execute a JQuery function by injecting it into the page? IT CAN'T be attached to the .ready function. The reason is that the user will be uploading an image via iframe. I need JCrop to execute after I display the uploaded image. echo "<script>$('#pictures_step1_right_bottom1', window.parent.document).html('<img id=\"cr...

how to pass varible in function so eclipse can detect its type and work with intelli sense ?

how can we pass a variable or what we can do inside the method, so eclipse can show the intellisense. ...

do something special when user input empty line

Hi, I'm just starting to study C. I have a program that prints a menu and let users choose what to do step by step. Now I would like to return to the main menu whenever the user enters an empty line, but how can I do that? I think I can make a function that return the program to the main menu, but when to call that function? I know it's...

Can I add a function to enums in Java?

Hi, I have an enum, which looks like public enum Animal { ELEPHANT, GIRAFFE, TURTLE, SNAKE, FROG } and I want to do something like Animal frog = Animal.FROG; Animal snake = Animal.SNAKE; boolean isFrogAmphibian = frog.isAmphibian(); //true boolean isSnakeAmphibian = snake.isAmphibian(); //false boolean isFrogReptile = fr...

PHP import functions

Hi, I'm trying to find the best pragmatic approach to import functions on the fly... let me explain. Say I have a directory called functions which has these files: array_select.func.php stat_mediam.func.php stat_mean.func.php ..... I would like to: load each individual file (which has a function defined inside) and use it just like ...