w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Creating an object containing functions using jquery extend
As far as I can see the only sensible option is a global object. If you want to access something from anywhere it needs to be global. If you look at most utility libraries e.g http://underscorejs.org/ you will see the same thing. They use a global namespace (similar to your MyApp object) which is just named '_'. If you try to add the functions to each object individually you will be duplicating them in memory for each object which is a waste.

Categories : Jquery

jQuery Masonry: Creating dynamic container to fill page with content (simulates a tiled background)
You need to add "float: left" and "margin: 0 auto" in order to make them work the way you want. .photo { width: 25%; float: left; margin: 0 auto} http://jsfiddle.net/mastermindw/Wuwsh/2/

Categories : Jquery

Creating a list to hold objects in C++
Your list should either be of type std::list<node*> or you should insert a node object (and not a pointer to one). node *aNode = new node(14, 32); std::list<node*> dataSet; dataSet.insert(dataSet.begin(), aNode); or node aNode(14, 32); std::list<node> dataSet; dataSet.insert(dataSet.begin(), aNode);

Categories : C++

What type of Container should I use to hold a 2D Tile Based World's Tile Objects?
I think you should have a map from co-ordinates on the world to a vector of what things are contained at those co-ordinates in the world. As in, if I have a class Thing that represents any thing that can be on a space in the game, and a class Position with x and y parameters, I would have this: map<Position, vector<Thing>> initialized with one vector<Thing>, initially empty, for every position in the game (all 10000 of them). This gives you a useful property: Spatial partitioning. If I want to figure out what things are around me, I just have to check in the map at nine different positions. If I were to go the other way, and have one big list of Things unpartitioned by where they are, I would have to look at every single Thing in the game to make sure I'd see every s

Categories : C++

Can stl functions that work on each member of a container accept external parameters?
Here is an example that uses for_each to update each element in abc: std::for_each(abc.begin(), // Start of range abc.end(), // End of range [=](int &value) // The operation to apply { value=(value-min)/(max-min); }); Changing the sequence being iterated over by for_each is often frowned upon, despite the fact that for_each guarantees the order of traversal as well as how many invocations occur per element. However, to appease the naysayers, you may want to use transform instead which has no such guarantees (neither of the order of traversal nor of the number of calls of the predicate other than via a complexity guarantee {Note: the complexity has been modified to a guarantee of the number of calls in C+

Categories : C++

Memory overhead of anonymous functions vs named functions when used as Jquery callbacks
By design, the observer pattern only keeps one instance of the observer. The event handler then calls this observer multiple times, with other instances of an event object, which holds the event parameters: which element fired the event, what is the context,... etc So the handler is not duplicated, but referenced in each subject's 'listeners store'. Note: Kemal Dag also notes that anonymous functions by definition offer less performance then named function, I don't know if it is true, but if it is, the difference is negligible. Especially for a language as JavaScript, that uses anon functions so extensively, it can not afford a performance impact on it.

Categories : Javascript

2 jquery .click functions for one button . fire functions one after another
Try this, <script> var clientId=<%=Button1.ClientID%>; $(document).ready(function () { $("#"+clientId).click(function () { var con1 = confirm("message"); return con1; }); }); </script>

Categories : Javascript

Creating a PCL point cloud using a container of Eigen Vector3d
Since PCL seems to use a float[4] to store the points, when you specify pcl:PointXYZ, you will have to copy each element individually (not tested): pc.points.resize( v.size() ); for(size_t i=0; i<v.size(); ++i) pc.points[i].getVector3fMap() = v[i].cast<float>(); if you used a vector4d instead and ensured that the last coefficient of each element is 0, you could do a memcpy or even a swap (with a bit of trickery).

Categories : Misc

When creating an SAS for an Azure Storage container are there any issues with using utc time for the expiry?
This is correct, all start / expiry times are in UTCtime. Also be aware of clock skew as the server time may not be identical to the time on your client machine when generating the signature so allow for say 5 minutes to absorb this. There will be no issues if various users are in different time zones as the signature will be good until the UTC time as evaluated by the server based on time of access.

Categories : Asp Net Mvc

Creating a Container Property in a VBA Class which returns Indexed Items (Excel VBA 2003)
OK - I will retract my advice about always naming let/set and Get the same, since in this case you cannot, since the "input" and "output" types are not the same. So, in the sample below I've named the property which just returns one ingredient as Ingredient Class "clsSASS": Dim pIngd As Collection Property Set Ingredients(c As Collection) Set pIngd = c End Property Property Get Ingredient(v As Integer) As String Ingredient = pIngd(v) End Property Regular module: Sub Tester() Dim c As New Collection Dim s As New clsSASS c.Add "bacon" c.Add "lettuce" c.Add "tomato" Set s.Ingredients = c Debug.Print s.Ingredient(1) 'bacon Debug.Print s.Ingredient(2) 'lettuce Debug.Print s.Ingredient(3) 'tomato End Sub

Categories : Excel

Functions creating objects in C++
The proper way would probably be to either create a constructor that takes the value as an argument: struct obj { obj(int f) : first(f) {} // ... }; // ... obj myobj(2); Or to have a setter function: struct obj { void set_first(int f) { first = f; } // ... }; // ... obj myobj; myobj.set_first(2); The above methods can of course be combined, so you both have a specialized constructor and a setter method. Although the setter method may be skipped since you are using a structure with only public member variables.

Categories : C++

Returning an array of functions: creating closures
There multiple "issues": The IIFE (function(i, array) { ... }(i, array)); has no benefit at all here. If you remove it the code will have the exact same behavior. If you want to capture the current value of i and array, you would have to move it inside the for loop. Your function definition is incorrect. funcs[i] = function(i, array) { return fn(array[i]); }; Inside the function, array[i] will refer to the arguments you pass to the function. If you don't pass any, they will be undefined and the code will throw an error. That is, with that definition, you would have to execute the functions like so: for (var i = 0; i < arr.length; i++) { funcs[i](i, array); } which kind of defeats the purpose of generating the functions in the first place. If you want to create a closure

Categories : Javascript

What are the Joomla 2.5 Core Functions for Creating Module?
The process is pretty simple and well explained on the Joomla Doc's website — you can start at the Module Development landing page.

Categories : Function

Passing a boolean to a function instead of creating two functions
I would say this is a BIG no-no due to the following reasons : Readability : There is only a very minor difference between the two keywords setVisible() and setInvisible() and its easy to mis-read while scrolling through 100s of lines of code. Semantics : Having 2 distinct setXXX() and setYYY() functions implies that there exist 2 different properties. While you will know that both of the map to the same internally, this may NOT be obvious to someone new to your library/API. Logic : In addition to the set functions, you would be implementing the corresponding getVisible() and getInvisible() for good measure as well. With code snippets like the following sure to cause enough confusion. setVisible() ... getInvisible() (wait, what??) setInVisible() ... getVisible() (whats th

Categories : Function

Is there any performance value in creating local copies of Lua functions?
The main motivation is probably performance because access to global variables requires a hash table lookup while access to local variables does not. However, you should measure the difference in your program. Don't overdo it. Note that you don't need to use different names: you can write local print=print etc so that the rest of your program does not really need to know whether these variables are local or global. Finally, there is a semantic difference when you save the value of a global variable into a local one: you are doing early binding; if your program calls an outside module that uses the same function, it will use the current value, not the frozen one you have. In other words, later redefinitions of say print do not affect you. For a longer discussion of performance, read Ch

Categories : Performance

How can I break up my Matlab code into functions without creating many files?
There is not way to declare multiple canonical functions in Matlab in a single file. However, using anonymous functions and functional programming techniques you may achieve some of your desired effect. I recommend the series on functional program from Loren on the Art of Matlab - I use these techniques on a regular basis. http://blogs.mathworks.com/loren/2013/01/10/introduction-to-functional-programming-with-anonymous-functions-part-1/ http://blogs.mathworks.com/loren/2013/01/24/introduction-to-functional-programming-with-anonymous-functions-part-2/ http://blogs.mathworks.com/loren/2013/02/07/introduction-to-functional-programming-with-anonymous-functions-part-3/

Categories : Matlab

Creating a class to store callback functions, is this method okay?
You could use an interface interface ICallBack { public function onStart(); public function afterCycle(); public function onEnd(); } //So all the methods in ICallBack must be implemented within CallBack class CallBack implements ICallBack { public function onStart() { //blah } ... } function doStuff(arg1, arg2, ICallback $callback){ //Init vars $var1 = ... $var2 = ... $callback->onStart();//callback.. .... }

Categories : PHP

Dynamically Creating Functions and Binding Buttons in Tkinter
The problem is that you are using the last value of self.button_id when you call the command once the buttons are created. You have to bind the current value of the local variable for each lambda with lambda i=i: do_something_with(i): def Create_Widgets(self): for i in range(1, 11): self.newmessage = Button(self, text= "Button ID: %d" % i, anchor=W, command = lambda i=i: self.access(i)) self.newmessage.config(height = 3, width = 100) self.newmessage.grid(column = 0, row = i, sticky = NW)

Categories : Python

Is there a shortcut for creating __init__ functions based on class attributes?
You could define a class that takes a dictionary as an input and does something like: for (k, v) in inital_dict.iteritems(): setattr(self, k, v) If you inherited from that class all your new classes would have the same method and you could invoke it with super.

Categories : Python

CodeIgniter creating Controller instance variables shared between functions
Your controller is not persistent (PHP is scripting language) In other words once you call function via browser( i.e. /GestirePost/A) it goes through series of files, loading classes, etc reaching the controller and printing what needs to be pritned. Eventually it finishes and stops there. So when you call another function (( i.e. /GestirePost/B) another instance is created and everything again starts from beginning (you class initializations, etc). So your A function, really never got executed from PHPs point of veiw. To use data from function call to function call (or rather form another instance to other) we use database or cookies.

Categories : PHP

C Programming Issues: Passing, creating, and returning structures in functions.
The line newImg->data = (PGMPixel*)malloc(newImg->x * newImg->y * sizeof(PGMPixel)); is wrong - it uses newImg->x and newImg->y before they are initialised. You should presumably use the values from img instead newImg->data = malloc(img->x * img->y * sizeof(PGMPixel)); I've made another small change to that line - you don't need to cast the return from malloc You also use the wrong PGMPixel instance later in the line img->data[... = img->data[... (it should presumably be newImg->data you are assigning to)

Categories : C

jQuery - Checking Check Box Values (Chaining jQuery functions Vs If Statment)
var booleee = $('#one,#two,#three,#four').attr('checked'); checks only whether the first (in this case #one) checkbox is checked. From the doc for attr Get the value of an attribute for the first element in the set of matched elements. it should be var booleee = $('#one,#two,#three,#four').filter(':checked').length > 0; Also in new versions(>1.6) you need to use the property 'checked' (.prop('checked')) instead of attr in the alternative you have a :checked filter so .is(':checked').

Categories : Javascript

Creating excel-like tables with math functions that interact in different html pages and with SQL
There are probably a few questions here. I will address the one about the database tables and how to link them. If you set up a table for users and their details then another for sessions, a new entry to sessions should be created for each time a user logs in. This should have the user_id and timestamp enabling you to link data about dates with the users. Then any data you record about the data enter during the session should be stored in tables that reference the session_id so that you can bring all of the darts back together. This is obviously a very simplistic overview of the schema, but should give you some idea.

Categories : SQL

2 jquery wired problems with jquery valid and show functions
put following code inside the ready function if (SiteMaster.UserIsAdmin == "True") { $("#adminpanel").show(); } $("#formid").validationEngine('attach',{ onValidationComplete: function(form, status){ if(status === true){ alert('the form is valid'); } } } });

Categories : Jquery

jQuery - How to pass multiple callback functions in jQuery ajax
You could easily define one callback function in which you would call multiple ones. $.ajax({ url: url, dataType: 'json', success: myGlobalCallback(data) }); function myGlobalCallback(data) { cb1(data); cb2(data); }

Categories : Jquery

Selection with jquery in Div Container
try this; fiddle: http://jsfiddle.net/kjSbj/ $('[id^=rezeile_]').each(function (index,val) { var temp = $(val).find('div > [id^=ztext_]').val(); var attrib1 = $(val).find('div > [id^=ztext_]').attr('id'); var attrib2 = $(val).find('div > [id^=zre_]').attr('id'); alert(temp); alert(attrib1); alert(attrib2); }); But I suggest you to use classes instead of id's for the repeating elments

Categories : Jquery

Creating template function overloads for pointer and non pointer type data held inside a container
For the second call to func, the second template parameter should just be int, not int *. Otherwise, the second func declaratino will look for a Vec<int **> as the first template argument (since it has its own pointer). func<Vec, int, int>(pv, 3); EDIT: as DyP mentioned, you can also leave out the template arguments completely, as the compiler should be able to deduce them from the actual function arguments.

Categories : C++

What options are there for creating universally accessible javascript functions (on the client side) in Meteor?
You should have a "client" folder in your Meteor root application directory. Inside it, create a "js" directory, and simply put your javascripts files in it. Then declare your global vars and functions this way : myVar=VALUE; myFunction=function(arguments){...}; Using the classic syntax (var myVar=VALUE;) will cause your symbols to be only local to the source file. In your "js" folder, you can play with the order in which scripts are loaded (read the docs for futher details), but basically, everything inside a "lib" folder gets loaded first, and inside folders, files are loaded using filename alphabetical order.

Categories : Meteor

Can't run jquery functions on forms added from jquery script
You need to use event delegation, since the formusername element is added dynamically $(document).on('click', '#formusername', function(){ alert("You clicked me!"); });

Categories : PHP

jQuery + CSS scroll to container part
try this => FIDDLE $('#nastepny').on('click', function(){ if(slidePosition<(slideCount-1)){ slidePosition++; pos = +(slidePosition * -900); $("#slide1_divs").css("transform"," translateX("+pos+"px)"); $("#slide1_controls div").removeClass("selected"); }else{ // other action... } });

Categories : Jquery

jQuery - How to find an index of an ID within another container DIV?
$("#main > div").index($("#two")) var isDivThere = $("#main > div").index($("#two")) != -1; Note: > is for filter only first level div's. So my solution will not work if you want to check the index of nested divs.

Categories : Javascript

Center Container for JQuery Packery?
DeSandro already has an example of a centered packery layout. The example is here. Basically it is just centered via CSS. I'm copying the code here too: HTML: <h1>Packery - centered</h1> <div class="packery js-packery" data-packery-options='{ "gutter": ".gutter-sizer", "itemSelector": ".item", "columnWidth": ".grid-sizer" }'> <div class="gutter-sizer"></div> <div class="grid-sizer"></div> <div class="item w2"></div> <div class="item"></div> <div class="item w2 h2"></div> <div class="item"></div> <div class="item w2"></div> <div class="item"></div> <div class="item h2"></div> <div class="item"></div> <div

Categories : Javascript

jQuery Rotate and container dimensions
There is a callback function which will be called when the animation is done.. In this function you can reset the img container width and height like this (not tested): var img = $('#img'); var cont = img.parent(); img.rotate({bind:{ click: function(){ $(this).rotate({ angle: 0, animateTo:180, callback: function(){ cont.css({ width: img.css('height'), height: img.css('width') }); } }) } } });

Categories : Javascript

jQuery wrap text without container
You might want to look at the .contents() method. This will give you text nodes as well as wrapped nodes, so you can wrap them. To adjust the example from the jQuery docs: $(".container") .contents() .filter(function() { // get only the text nodes return this.nodeType === 3; }) .wrap( "<span></span>" ); It sounds like you want to wrap the content after click, which I think might be quite difficult. If possible, it would be better to wrap the content before the user clicks, then apply a style to the span they clicked - this is much more straightforward. If you use the code above to wrap, you can then apply a handler like $(".container").on('click', 'span', function() { $(this).addClass('clicked'); });

Categories : Javascript

Toggle width of a container using jQuery
Following is the code as per your requirement so try this code: HTML <div id="container">this is container div</div> <div class="wrp">this is wrp div</div> <input type="button" value="toggle" id="toggle-button"> CSS #container { width:960px; background-color: red; } .wrp { width:1000px; background-color: green; } JS $(document).ready(function () { var setWidth = $.cookie("width"); if (typeof setWidth !== "undefined" && setWidth == "85%") { $('#container,.wrp').width(setWidth); // 85% width set using cookie } else if (typeof setWidth !== "undefined" && setWidth == "960px") { $('#container,.wrp').width(setWidth); // 960px,1000px(for wrp) width set using cookie } $('#toggle-button').

Categories : Jquery

Creating a user-defined function with SQL::Statement::Functions in Perl creates a syntax error
You are not using the module as it is intended. It's an extension to the SQL::Parser module that is used by DBDs to implement SQL syntax and functions. The documentation states: This module contains the built-in functions for SQL::Parser and SQL::Statement. All of the functions are also available in any DBDs that subclass those modules (e.g. DBD::CSV, DBD::DBM, DBD::File, DBD::AnyData, DBD::Excel, etc.). To me, that sounds like it has nothing to do with mysql. The DBD::mysql is used as a wrapper around a real mysql database. It just connects, forwards the queries, prepares them and so on. It does not parse them, however. That's what the database is doing, just like if you were to connect to an Oracle or MSSQL database. In those cases, the driver is like an API wrapper. On the

Categories : SQL

How to do an alert after appending elements to container using jQuery?
Looking at the docs appendTo() doesn't accept a second argument. you would have to do something like: $("SomeTextToAppend").appendTo(".container"); alert("appended"); Doing it the other way around with append() would look more like $(".container").append("SomeTextToAppend"); Hope this helps

Categories : Javascript

jQuery Adding and Removing Images from a Div Container
Simply by adding condition checking the src of the clicked image, you can see if you already added it. The condition look like this: if(!$('#imgBox').find('[src="'+src+'"]').length) Then, for removing the border, I saved the clicked element and reused it in the other click function. The final code look like this : if(!$('#imgBox').find('[src="'+src+'"]').length){ var theImage = $(this); $(this).css('border','1px solid #000'); $('#addText').hide(); $('#imgBox').append(addimg); //we need to be able to remove the image also. $('#imgBox img').click(function(e){ e.preventDefault(); theImage.css('border', 'none') $(this).remove(); }); } Fiddle : http://jsfiddle.net/LnqBt/5/

Categories : Jquery

javascript / jQuery : get selected text's container
window.getSelection().anchorNode - Gives you the DOM element where the selection started window.getSelection().focusNode - Gives you the DOM element where the selection ended Reference: https://developer.mozilla.org/en-US/docs/Web/API/Selection?redirectlocale=en-US&redirectslug=DOM%2FSelection

Categories : Javascript

JQuery, keep inner
If you give #num-text a height, you can vertically align it to the center using the absolute positioning you already have on it: #num-text { position:absolute; text-align:center; color:#eee; font-size:24px; width:100%; height: 24px; top:50%; margin-top:-12px; } See fiddle here: http://jsfiddle.net/hZSKA/1/ As a side note, it's probably possible to do this same effect using CSS3 but that may not be backwards compatible with older browsers.

Categories : Javascript



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.