Hi,
I want to const declare the this pointer received as an argument.
static void Class::func(const OtherClass *otherClass)
{
// use otherClass pointer to read, but not write to it.
}
It is being called like this:
void OtherClass::func()
{
Class::func(this);
}
This does not compile nad if i dont const declare the OtherCla...
Hello guys, I have some code which use 'this' pointer of class which calls this code. For example:
Some::staticFunction<templateType>(bind(FuncPointer, this, _1));
Here is I'm calling bind function from boost. But it doesn't matter. Now I have to wrap this code. I made a macro:
#define DO(Type, Func) Some::staticFunction<Type>(bind(F...
In Java, I have an object that creates a button. Inside that button's onclicklistener I want to reference the object that created the button.
Is there some easy way I can do this?
...
The following put the id name of each div inside the div as content:
<div id="divDiv">
</div>
<div id="divLink">
</div>
[...]
$('div').each(function() { $(this).prepend($(this).attr('id')) })
will work but
$('#divStatus div').prepend($(this).attr('id'))
will not. Why is that? I thought $(this) ...
I have a question relating to the usage of "this".
Suppose I have two classes A & B; their rough outline is as follows:
class A
{
public:
...
void AddB( B* b )
{
// inserts B into the vector v
}
private:
std::vector<B*> v;
};
class B
{
public:
...
void foo( void )
{
...
// Adds itself to th...
I'm doing this:
$("#bcdialog").dialog({
resizable: true,
height: 400,
width: 600,
modal: true,
autoOpen: false,
buttons: {
'cancel': function() { $(this).dialog('close'); }
'save': function() { $("#bcdialog form").submit(); }
}
});
I would like to know if it ...
I have a very strange question.
I have a class/function :
class MCBSystem {
[...]
template <class Receiver>
void setCallBack(int i, Receiver* receiver, void(Receiver::*function)(void*)) {
iCallBacks.at(i) = new CallBack<Receiver>(receiver, function, this);
};
};
And I inherit it (multiply) in another class :...
I have a form with labels and input fields. When clicking into a field I want to style the field with CSS and display some information about the input requirements in a div under the label.
The focus() and blur() events add the classes for styling the field just fine but trying to show/ hide the info divs triggers the methods on ALL fie...
Hi, straight and clear as the title says :)
Background:
I run into some tutorial and I realized that I missed some things...
So, I would really appreciate if anyone can point out any must_know_facts with an example.
Thanks!
...
I was working on a project for a while, trying to figure out what I was doing wrong, when I finally narrowed "the bug" down to the fact that the below code doesn't work as I expected:
function Alpha()
{
this.onion = 'onion';
function Beta()
{
alert(this.onion);
}
Beta();
}
alpha1 = new Alph...
Possible Duplicate:
jQuery $(this) vs this
In jquery sometimes I find that within a function I have to use $(this) because this won't work:
var listItems = $('li');
listItems.each(function(index) {
$(this).css({
})
})
Any ideas as to the reason why?
...
I am a java/php developer helping someone with actionscript. I don't understand why "this" is undefined in the below code. this is only a snippet of the code, but hopefully it's gives an idea of where i'm trying to reference "this". I'm trying to find out which movie the tween is moving so that i can load the next movie. Tweens are u...
Suppose I have JavaScript code like
myClass = function(){
function doSomething(){
alert(this); // this1
}
}
alert(this); //this2
What those two 'this' objects are refer for??
...
I have the following error when running the page below:
"this.testpublic is not a function"
test = function() {
var testprivate = function() {
this.testpublic();
}
this.testpublic = function() {
console.log('test');
}
testprivate();
}
new test();
Apparently w...
I'm a beginner to closures (and Javscript in general), and I can't find a satisfactory explanation as to what's going on in this code:
function myObject(){
this.myHello = "hello";
this.myMethod = do_stuff;
}
function do_stuff(){
var myThis = this;
$.get('http://example.com', function(){
alert(this.myHello);
...
Is it possible to use a :selector with the following in jQuery?
$('.galler_attr').bind('click', function() {
$(this:first-child).css('color', 'red');
});
...
I have a page of search results, each of which has an icon to add each result to a group (listed on the page in a hidden UL element: display:none;).
Right now it works... but when I click on the icon for one result listing... the UL appears under every single result.
I need it to only show up for the result listing that I am clicking t...
I have created a CalendarViewerPortlet custom object JS object. In this object, I am storing things like the portlet's id and its context path. The object also has many custom methods, some to get/set the member variables and some to do specific things.
When I try to reference a function of the object using "this." inside of a jQuery fu...
How can I pass the $this (the self keyword) to a function in Jquery
$(document).ready(function()
{
$('.nav a').click(function() {
var direction = $(this).attr("name");
submit_form($(this))
});
function submit_form(this)
{
// do some stuff with 'this'
...
Here's a function for use as an event handler that makes use of this:
function validate() {
if (this.val() == '') {
return false;
}
}
$(':input').change(validate);
Here's the same function rewritten to take an argument, so that I can call it explicitly:
function validate(field) {
if ($(field).val() == '') {
return fals...