I was wondering what happens to the code contained in an <mx:Script> tag. If I define a function tehre, it just becomes a member function of the generated class. But I noticed that it seems OK for the compiler if I just write some (static) method calls there (specifically, I call Font.registerFont()). I feel kind of guilty for doing this, because I have no idea what's really happening and when the code gets executed.
In my adventures studying the boost libraries, I've come across function signatures that have parameters which are a reference to a reference to an object.
Example:
void function(int && i);
What is the purpose/benefit of doing it this way rather than simply taking a reference to an object? I assume there is one if it's in boost.
I am trying to make a firefox extension which looks at all the new pages that a user views and look at the URL. I was looking at the nsINavHistoryObserver interface and was interested in the onVisit function. Is there a way to create an event listener that can listen to whenever the onVisit function is called?
Thanks
I am using the Jquery Validation plug-in, however i need to add a "custom rule", i have 2 date fields and i need to ensure that the end date is not less than the start date. My problem is how to pass the two fields in as elements.
As i understand u set up a custom function something like this :
function customValidationMethod(value, element, params){ }
But can't see how i could use it with two fields, if anyone has any ideas it would be greatly appreciated.
I cant seem to get any consistent info on this. Different sources appear to say different things and trhe venerable php.net iteslf (appears) not to explicitly state this - although I must admit, I only had a quick look.
In cases where I am passing around 'heavy' objects, I need to pass by reference, but I dont want to keep typing:
function foo(TypeName& $obj)
if I can get away with simply,
function foo(TypeName $obj)
So what does the standard say?
Write a function, called constrainedMatchPair which takes three arguments: a tuple representing starting points for the first substring, a tuple representing starting points for the second substring, and the length of the first substring. The function should return a tuple of all members (call it n) of the first tuple for which there is an element in the second tuple (call it k) such that n+m+1 = k, where m is the length of the first substring. Complete the definition
def constrainedMatchPair(firstMatch,secondMatch,length):
I want to define a function replicate to replicate a list of numbers by its value using only list comprehension, for example:
replicate [5,1,3,2,8,1,2]
output: [5,5,5,5,5,1,3,3,3,2,2,8,8,8,8,8,8,8,8,1,2,2]
I know this would be easy to use the 'replicate' built in function but only list comprehension is allow, how can I do this?
THANKS!
I have an ajax post and in the controller I return nothing. In case there is a failure will the error message displayed with the follwoing code?
[AcceptVerbs(HttpVerbs.Post)]
public void Edit(Model model)
{
model.Save();
}
$.ajax({
type: "POST",
url: '<%=Url.Action("Edit","test") %>',
data: JSON.stringify(data),
contentType: "application/json; charset=utf-8",
dataType: "html",
success: function() {
},
error: function(request, status, error) {
alert("Error: " & request.responseText);
}
});
Hi all,
I am trying to write all my query code in an object oriented way. But I don't know how to implement this for each click function and hover function etc. I also wanted to know:
What are the advantages of writing query in object oriented way?
For query what is better the object oriented way or in the ordinary way?
I try to prevent the Browser from using the :hover effect of the CSS.
$("ul#mainFilter a").hover(
function(o){ o.preventDefault(); ...do my stuff... },
function(o){ o.preventDefault(); ...do my stuff... });
I tired it with return false; to but it does not work.
Does anyone know how to do this?
I'm newly using CODE::BLOCKS+mingw compiler
If I don't type return 0 at the end of program,I can see that main() is returning some integer,I learnt that main() returning 0 infers program executes successfully.I don't find any flaw in my code, why is it returning some integer?
secondly
any function returns its value to its function call, to where does main() return its value?
Hi guys,
I'm testing a jQuery ajax post method on a local Apache 2.2 server with PHP 5.3 (totally new at this). Here are the files, all in the same folder.
html body (jQuery library included in head):
<form id="postForm" method="post">
<label for="name">Input Name</label>
<input type="text" name="name" id="name" /><br />
<label for="age">Input Age</label>
<input type="text" name="age" id="age" /><br />
<input type="submit" value="Submit" id="submitBtn" />
</form>
<div id="resultDisplay"></div>
<script src="queryRequest.js"></script>
queryRequest.js
$(document).ready(function(){
$('#s').focus();
$('#postForm').submit(function(){
var name = $('#name').val();
var age = $('#age').val();
var URL = "post.php";
$.ajax({
type:'POST',
url: URL,
datatype:'json',
data:{'name': name ,'age': age},
success: function(data){
$('#resultDisplay').append("Value returned.<br />name: "+data.name+" age: "+data.age);
},
error: function() {
$('resultDisplay').append("ERROR!")
}
});
});
});
post.php
<?php
$name = $_POST['name'];
$age = $_POST['age'];
$return = array('name' => $name, 'age' => $age);
echo json_encode($return);
?>
After inputting the two fields and pressing 'Submit', the success method is called, text appended, but the values returned from ajax post are undefined.
And then after less than a second, the text fields are emptied, and the text appended to the div is gone. Doesn't seem like it's a page refresh, though, since there's no empty page flash.
What's going on here? I'm sure it's a silly mistake but Firebug isn't telling me anything.
I'm wondering if it's possible to use a wildcard to select multiple cookies. I'm using jquery to save various scroll position and would like to clear them out in one go. At the moment I clear them out individually as below
function clearScroll(elementID) {
if ($.cookie) {
$.cookie(elementID + '_scrollpos', 0);
}
}
What I'd like is a clear all something like below.
function clearAllScroll() {
if ($.cookie) {
$cookie([name$='_scrollpos'],0);
}
}
Is this possible?
I'm trying to enable a button but the button that I would enable in this function changes. I have an array of the buttons but when I use the .enabled on the array index I want it says that this doesn't work for IDs.
I have used this array to set the text of each button before using:
[[ButtonArray objectAtIndex: Index] setTitle:(@"blahblahblah") forState: UIControlStateNormal];
is there any way to use a similar function call to enable and disable?
I'm looking for a function that can accurately represent the distance between two colours as a number or something.
For example I am looking to have an array of HEX values or RGB arrays and I want to find the most similar colour in the array for a given colour
eg. I pass a function a RGB value and the 'closest' colour in the array is returned
I'm having trouble referencing the desired object when I've namespaced functions.
No problems here:
obj.test = function() {
// this == obj
}
But I'm getting tripped up when I namespace:
obj.namespace.test = function() {
// this == namespace
}
In the latter example, I know this references namespace, but I want to reference obj. How can I do it?
Hi,
I am trying to make a script that updates the captcha image, that is loaded through live() function... It works, but it only updates the image 1 time on firefox, 2 times on safari... How can I make this to work multiple times?
jquery 1.4.2
relevant part of code:
/* captcha image change */
var rand = Math.random();
$('a.captcha_refresh').live('click', function() {
$('img.captcha').attr("src", 'captchashow.php?sid=' + rand);
});
thanks,
brm
Hi,
i have these methods in module1/actions/actions.class.php:
public function executeMethod1(sfWebRequest $request){
$a = 10;
sfContext::getInstance()->set('a', $a);
return $this->redirect('module1/method2');
}
public function executeMethod2(sfWebRequest $request){
echo sfContext::getInstance()->get('a');
}
When i execute module1/method1 i get this error:
"The "a" object does not exist in the current context."
Any idea?
Javi
I've got a Registry class and there are a few Registry values that I want to access from within that Registry class. (There is a bit of a calculation with these values so I thought I'd just put all that code right in the Registry Class itself).
So we might have something within our RegistryRoutine.cls like:
Function GetMyValue() as integer
Dim R as new RegistryRoutine
<calculations>
GetMyValue=R.GetRegisetryValue (HKEY, key, value, etc.)
End Function
In java, when you pass an object to a method as a parameter, it is actually passing a reference, or a pointer, to that object because objects in Java are references.
Inside the function, it has a pointer to that object which is a location in memory. I am wondering where this pointer lives in memory? Is a new memory location created once inside the function to hold this reference?
Hi all,
I have got a simple HTMl form with one field as follows:
<input type="text" name="data['User']['user_id']" id="data['User']['user_id']" value="1">
$(document).ready(function(){
$("#data['User']['user_id']").mouseover(function(){
alert("hello");
});
});
The code couldn't work,
I think it may be the name of the Input text field that caused the problem,
but I don't know how to alter it
because this is the naming convention in CakePHP.
I want to fade in a background of an entry within a div - this is to show the user what the most recent entry is on page load.
I want it to do it on page load, without having to click or hover or anything, just when the page loads.
I have this:
$(document).ready(function() {
$('#box').fadeIn(5000, function() {
// Animation complete
});
});
Is it something like pageLoad?
Any help is appreciated.
In an app I'm profiling, I found that in some scenarios this function is able to take over 10% of total execution time.
MSVC++ 2008 compiler is being used, for reference... I don't recall if modf maps to a single instruction or if there is likely any way to make it faster.
see also here for similar question on sqrt function
I am looking for some easy jquery solution for hover images.
Like if i define a class. them jquery should get the current image like
abc.png then chnage that to abc_on.png
and then put that to on hover image
How can i do that.
i don't want to add function for every button.
Just one function and it do all.
My Images all usually imagename.png or imagename_on.png