I am trying to figure out how to keep my page variables in my application from being defined globally. I've come up with a few methods but am wondering if there is a general standard approach people use.
I've got my plugin design pattern down using this approach: http://www.virgentech.com/blog/2009/10/building-object-oriented-jquery-plugin.html. But I'm just not sure how to handle my page level encapsulation.
I have an Ajax-enabled CRUD application. If I display a record from my database it shows that record's values for each column, including its primary key.
For the Ajax actions tied to buttons on the page I am able to set up their calls by printing the ID directly into their onclick functions when rendering the HTML server-side. For example, to save changes to the record I may have a button as follows, with '123' being the primary key of the record.
<button type="button" onclick="saveRecord('123')">Save</button>
Sometimes I have pages with Javascript generating HTML and Javascript. In some of these cases the primary key is not naturally available at that place in the code. In these cases I took a shortcut and generate buttons like so, taking the primary key from a place it happens to be displayed on screen for visual consumption:
...
<td>Primary Key: </td>
<td><span id="PRIM_KEY">123</span></td>
...
<button type="button" onclick="saveRecord(jQuery('#PRIM_KEY').text())">DoSomething</button>
This definitely works, but it seems wrong to drive database queries based on the value of text whose purpose was user consumption rather than method consumption. I could solve this by adding a series of additional parameters to various methods to usher the primary key along until it is eventually needed, but that also seems clunky.
The most natural way for me to solve this problem would be to simply situate all the Javascript which currently lives in external files, in the <head> of the page. In that way I could generate custom Javascript methods without having to pass around as many parameters.
Other than readability, I'm struggling to see what benefit there is to storing Javascript externally. It seems like it makes the already weak marriage between HTML/DOM and Javascript all the more distant.
I've seen some people suggest that I leave the Javascript external, but do set various "custom" variables on the page itself, for example, in PHP:
<script type="text/javascript">
var primaryKey = <?php print $primaryKey; ?>;
</script>
<script type="text/javascript" src="my-external-js-file-depending-on-primaryKey-being-set.js"></script>
How is this any better than just putting all the Javascript on the page in the first place? There HTML and Javascript are still strongly dependent on each other.
Hey there,
I've heard about web scraping software that can take data from a webpage. i'm building an android app and I want to take information from this site www.menupages.ie
All I need is the names of the restaurants, and typing them in myself would be very tedious.
Can someone tell me how i'd go about doing this in eclipse, what methods i need etc.
I dont know anything about it.
Thanks alot.
Hi there
Can someone explain the differences between an Observable and a ConnectableObservable? The Rx Extensions documentation is very sparse and I don't understand in what cases the ConnectableObservable is useful.
This class is used in the Replay/Prune methods.
I'm speaking of this module:
http://docs.python.org/library/operator.html
From the article:
The operator module exports a set of
functions implemented in C
corresponding to the intrinsic
operators of Python. For example,
operator.add(x, y) is equivalent to
the expression x+y. The function names
are those used for special class
methods; variants without leading and
trailing __ are also provided for
convenience.
I'm not sure I understand the benefit or purpose of this module.
In the following Groovy snippet, I attempt to replace both the hashCode and toString methods
String.metaClass.toString = {-> "override" }
String.metaClass.hashCode = {-> 22 }
But when I test it out, only the replacement of hashCode works
String s = "foo"
println s.hashCode() // prints 22
println s.toString() // prints "foo"
Is toString somehow a special case (possibly for security reasons)?
hi! all,
I was tryin to convert a QSting to char* type but by following methods,but those does'nt seem to work.
// QLineEdit *line=new QLineEdit();{just to describe what is line here}
QString temp=line->text();
char *str=(char *)malloc(10);
QByteArray ba=temp.toLatin1();
strcpy(str,ba.data());
can you elobrate the possible flaw with this method ,or tell alternative method.
Hello, I have an application that have EF 16 classes that share this information: They all are classes only with a key field and a description.
I think it should be a waste if I make a controller with just 1 method just to present a form to fill these classes info, then I was thinking in to make a generic form(with key, description) and dynamically fill the right class through a sort of selection the selected info in any way, any good suggestion or pattern to do that? Where the generic methods should be located.
I have a WSDL 1.1 file which describes my Web Service. Now I need get access to its methods using ASP.NET 3.5
I tried to use wsdl.exe utility but I think that this utility use only WSDL 2.0 format.
I draw figure in Flsh ID with JSFL methods, for example
// draw rectangle
doc.addNewLine({x:0, y:0}, {x:2000, y:0});
doc.addNewLine({x:2000, y:0}, {x:2000, y:500});
doc.addNewLine({x:2000, y:500}, {x:0, y:500});
doc.addNewLine({x:0, y:500}, {x:0, y:0});
// how can I fill it, because this way doesn't work
doc.setFillColor('#0000ff');
Is there a way to query an embedded flash element to determine the available methods that can be executed on it via JavaScript?
Edit:
It appears that in IE it's as simple as
for ( i in flashNode ) {
alert(i);
}
After much clicking, they will be some of the very last members enumerated.
Still not able to determine this in Firefox though.
When pushing a viewcontroller using UINavigationController into the view:
What is necessary for it to trigger
viewDidAppear: and viewWillAppear: ?
What makes it fail to not trigger viewDidAppear: and viewWillAppear: ?
We are having a hard time relying on wether those methods gets triggered or not.
If I have a class "person" with a property $name and its getter(get_name()) and setter(set_name()) methods, then after instantiating the objects and setting the property i.e.
$paddy = new person();
$paddy->set_name("Padyster Dave");
echo "Paddy's full name: ".$paddy->name; //WHY THIS IS NOT RECOMMENDED...
In the above code $paddy->name;WHY THIS IS NOT RECOMMENDED?
An activity indicator view is useful in many applications.
Any ideas about how to add, activiate and dismiss an activity indicator view on iPhone?
All the methods for this are welcomed here.
I'm looking to create an ID system for cataloging images. I can't use md5() since that will change if I alter the EXIF tags of the image.
I am currently using the SHA1 checksum computed by imagemagick. It works perfectly, but it's really, really slow on larger images (~15 seconds on a quad-core xeon for a 21 megapixel JPG).
Are there any other "visual" methods of uniquely identifying an image that would be faster?
Thank you.
Hello everybody
It's really dream to be programmer for me.So i always wanted to be .I had so small knowledges from commodore basic which i couldn't figure out anything in it .Then i tried to learn Visual basic 6 by myself and result wasn't good as i expected because i even didn't understand classes.Then i left to learning programming and to dream to be programmer.
But challenge hadn't finished yet . After all of these i started to learn c# and i did chess engine which i hadn't believe that i can create one.I sometimes feel that i understand many thing about programming like knowing classes ,inheritance,abstract class and methods why exist , interfaces ,extension methods ,static classes ,threads. but i am not expert all in it . i just know that as i need . i don't know still i will learn many thing about these.i have also learned html, css2 , php and database concepts a little sql ,tables relations between primary keys etc but i haven't used them in praticaly . i just did some samples so i feel i am lack of knowledges.
As a result still i can't evaluate my skills and can't decide what is my level.I just feel myself one step ahead of junior sometimes :) . Still can't decide that it is time to job seeking. While searching job on web i have never seen a junior advertisement. All looking for a good experiencing one.Nobody care about juniors.
When found job advertisement which i feel sufficient myself a little then i start to feel that i think i can't do what they want from me and loosing job after have it in short time would leave many crap feelings into my low self-confidence.
Please advise me something ...
Also i want to ask some of concentrate questions.
1) If i enter a job which i can't provide their expectations should be in employers responsibility to test me while apply the job ?
2) If i answer "yes , i can " questions which is abstract(for example: can u do something like this) would be my responsibility ? Because such abstract questions is not clear and can't know before start it what i really can or not .
3) i have no professional experiences in this job so i even don't know how teams working on projects but a friend of me said that programmers only write method bodies while seniors create all project.So it looks what i can do really easy but i feel that small companies doesn't work like this so it is better work in a big company for starting who has seniors?
4)last applied job was looking for c# . net developer but then i learn that they need .net web developer.Does it take long time to learn specific sides of web programming while knowing c# desktop programming ?
Thanks for all answers since now.
Hey, I'm creating a little GLUT application and need help with hiding/removing the console window.
I am developing on windows and I already know of the various methods to hide the console window on a windows system, however is there no portable method of hiding it?
Thanks...
I'm looking for a way to set a selection in a textarea in Internet Explorer. In other browsers, this works just fine:
textarea.selectionStart = start;
textarea.selectionEnd = end;
In IE, I assume I have to use createRange and adjust the selection somehow, but I cannot figure out how.
Extra bonus points for a link to a proper documentation about createRange and associated methods, MSDN isn't helping out much.
I was wondering if PHPStorm by Jetbrains has a tool to sort the methods in my JavaScript object by name. If not are there any other tools that can do this for me?
Ext.regController("dashboard", {
goToShoppingCart:function() {
Ext.dispatch({
controller:"shoppingCart",
action:"loadCart"
});
},
goToDashboard:function() {},
goToContact:function() {}
}
);
to
Ext.regController("dashboard", {
goToContact:function() {},
goToDashboard:function() {},
goToShoppingCart:function() {
Ext.dispatch({
controller:"shoppingCart",
action:"loadCart"
});
}
}
);
This is only for organization.
Thanks
I'm having serious problems with accepting payments.
I'm passing the total amount in a hidden field
<input type="hidden"
name="checkout-flow-support.merchant-checkout-flow-support.shipping-methods.flat-rate-shipping-1.price"
value="129.00"/>
Some of the users changed this value to 2 using firebug and submitted the form. Instead of getting $129, we only received $2.
I have no idea how to proceed this anyone help me quick .
I'm new to Python 3 and so far it seems like a decent language. I really like the string manipulation methods you can use and they are pretty radical. :)
I'm stuck however in thinking of a project to do with Python. Is there a site similar to Coding4Fun but for Python?
Community Wiki because I think this question is really interesting. :D
I would like to create a base class that is somewhat generic for all of my entities. The class would have methods like Save(), Delete(), GetByID() and some other basic functionality and properties. I have more experience with Linq to SQL and was hoping to get some good examples for something similar in the EF. Thank you.
I'm trying to set a page that displays the visitor's IP. All the methods I have tried show an IP different from the IP my computer has. I've tried:
Looking up http://www.whatismyip.com/automation/n09230945.asp
Using socket.getaddrinfo(socket.gethostname(), None)[0][4][0]
How can I find the real IP of the visitor?