|
Not that I've seen. You'll need to trigger the remainder of the code from the anonymous function which handles the event.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Well, I don't like doing it this way, but I am using what I call a stair-step approach:
function doIt()
{
doStep1();
this.doStep1 = function()
{
do something
do something
$(img).load(function()
{
if (this.complete === true)
{
doStep2(img.naturalWidth)
}
});
}
this.doStep2 = function(width)
{
calc scale
do other suff
$(obj).dosomeOtherAsynchThing(function()
{
doStep3();
});
}
this.doStep3 = function(width)
{
do something
etc...
}
}
Now that the image is actually being displayed, I can now try to finger out why the scale isn't being set as expected in the context.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
Hello, i am using play framework 1.2.3 with eclipse, i want to call a controller method with this java request, but when i click the button nothing happens. anyone have an idea what went wrong?
Best regards.
<script type="text/javascript">
$("#request").click(function(){
var reqphone = $('#reqPhone').val();
var key = $('#accesscode').val();
var fro = $('#from').val();
var too = $('#to').val();
var myPhone = $('#userPhone').val();
var action = #{jsAction @reversetest(':consumer',':accessKey', ':usersPhone', ':reqPhone',':from', ':to') /};
$.ajax({
type:"GET",
url = action({consumer: 'marcus', accessKey: key, usersPhone: myPhone, reqPhone: reqphone, from: fro, to: too}),
success: function (response)
{
$("#XMLArea").val(response);
}
});
})
</script>
<input type="button" id="request" class="button" name="request" style="float: left; top: 50px; left: 310px; position: absolute;"></input>
modified 27-May-13 7:21am.
|
|
|
|
|
I don't know the framework but I am curious how is action returning a usable url??
marcusKam wrote: url = action({consumer:
I would probably start with some breakpoints and step through this. maybe also add an error handler for that ajax call.
best of luck.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
thanks both for your answers, play framework generates a useable urlwhen the action method is called.
I had to move my from the "<head>" section too the "<body>" section cause my button wasnt able to access the script otherwise for some too me unknown reason, anyway i used the jquery .load method and filled it with "action{data}" and it worked as supposed to.
Thanks for the help
|
|
|
|
|
marcusKam wrote: I had to move my <script> from the "<head>" section too the "<body>" section cause my button wasnt able to access the script
any script that will interface the document you want to put towards the bottom of your page. this is especially true when adding button handlers.
you may have seen it work 'sometimes' but when you add handlers like this in the <head> of your document you open yourself up to errors where the handler never gets called.
marcusKam wrote: play framework generates a useable urlwhen the action method is called.
I hate to say kind of like backbone but I am guessing this is similar in that it's for supporting another MVC framework on the client with a REST backend. pretty cool.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Yeah you are right! I'm not very experienced at java yet, i've only worked in visual studio before, and when you put the scripts in ur in vs it works perfectly fine.
of course i meant the JsAction method makes the action variable and useable Url and when u post
action{data: "hello"} it just adds the values to the url.
|
|
|
|
|
Everything inside the Ajax call should be a JSON object. In your second line of it, you have = instead of :
Fix that, and fix the URL of your action and this should work.
|
|
|
|
|
function OnTargetDrop(){
alert(oDragItem.value);
alert(oDragTarget.value);
var temp = oDragTarget.value;saving a value of target div that brings the position of dragged box
if arrived target is <div class="DropTarget" value="2"> brings 2 as value
var tmp_val = oDragItem.value-0;
var $node = $("#order").children().eq(temp);
var org_val = $node.text()-0;
$node.text(org_val+tmp_val);
oDragItem.style.position="";
oDragTarget.appendChild(oDragItem);
if (navigator.platform=="iPad") MakeDragable(oDragItem);
}
<blockquote class="FQ"><div class="FQA">Quote:</div>
<td>
{
<div class="DropTarget" value="1">
<div class="Dragable" seletable="no" style="background-color:#eee8aa;" value="10">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#87cefa;" value="10">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#66cdaa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#eee8aa;" value="10">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#eee8aa;" value="30">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#87cefa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#66cdaa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#eee8aa;" value="10">cb13030940</div>
</div>
<blockquote class="FQ"><div class="FQA">Quote:</div></td></blockquote>
</blockquote>
<blockquote class="FQ"><div class="FQA">Quote:</div><td align="center">
<div class="DropTarget" value="2">
<div class="Dragable" seletable="no" style="background-color:#eee8aa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#87cefa;" value="10">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#66cdaa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#eee8aa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#87cefa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#87cefa;" value="20">cb13030940</div>
<div class="Dragable" seletable="no" style="background-color:#66cdaa;" value="10">cb13030940</div>
</div>
</td></blockquote>
<blockquote class="FQ"><div class="FQA">Quote:</div>
<blockquote class="FQ"><div class="FQA">Quote:</div><%
int sum1, sum2;
%></blockquote>
<tr align="center" id="order">
<td width = "25">Order Quantity</td>
<td><%=sum1%></td>
<td><%=sum2%></td>
<td>sum3</td>
<td>sum4</td>
<td>sum5</td>
<td>sum6</td>
<td>-</td>
<td>-</td>
<td>-</td>
</tr></blockquote> }
}// when the value gets 1, the value in the div's sum
becomes sum1. when the value gets 2, the value in the div's sum becomes sum2. when div moves, sum1 or sum2 change depends on specific value,
|
|
|
|
|
What's your question?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
can I recommend that you use.
http://jsfiddle.net/[^]
and then discuss the problem that you are having and need help with.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
I want to add GO button. After press the go button then stage3 will open in New tab.
Please help me and add the Line in below Script and
reply on my email :abmanish71@gmail.com
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Combo Boxes</title>
</head>
<body>
<form name="isc">
<select name="example" size="1" onChange="redirect(this.options.selectedIndex)">
<option selected>Select your department</option>
<option>ACCT</option>
<option>BACC</option>
<option>BMGT</option>
</select>
<select name="stage2" size="1" onChange="redirect1(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select2--------------</option>
<option value=" " selected>---Select2--------------</option>
</select>
<select name="stage3" size="1" onChange="redirect2(this.options.selectedIndex)">
<option value=" " selected> </option>
<option value=" " selected>---Select3----------------</option>
<option value=" " selected>---Select3----------------</option>
</select>
<input type="button" name="next" value="Next" onclick="window.location=stage3.options[stage3.options.selectedIndex].value;" style="font-family:Arial;Z-INDEX: 105; POSITION: absolute; TOP: 20px" enable>
<script>
</script>
|
</form>
</body>
</html>
____________________
Thanks & Regards
Manish Kumar
E - mail : abmanish71@gmail.com
modified 24-May-13 23:23pm.
|
|
|
|
|
What do you mean by "stage3 will open in New tab?" Isn't stage3 a dropdown list?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I'm trying to load an image and retrieve its width/height. The image appears to be okay, but width/height are zero. The image isn't part of the page (yet), I'm simply creating it for later. Anyone got any help for me?
var id = this.FileName.replace(".png", "").replace(".jpg", "") + "_" + index;
var src = this.Path + this.Filename + "?" + new Date().getTime();
this.ItemImage = new Image();
$(this.ItemImage).attr(
{
'src': src
,'id' : id
});
this.Width = $(this.ItemImage).width();
this.Height = $(this.ItemImage).height();
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
John Simmons / outlaw programmer wrote: The image isn't part of the page (yet), I'm simply creating it for later.
That is the answer to your problem.
since the image isn't loaded yet the browser won't set the width and height properties. will the image ever be loaded by the browser??
maybe try something like...
$('<img />').attr('src', 'http://urdomain.com/name.jpg').load(function(){
if(true === this.complete) {
var width = this.width;
var height = this.height;
} else {
}
});
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Your suggestion didn't work. I'm going to try adding a hidden div to the document, and then add images to that div. Maybe that will do what I need...
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
John Simmons / outlaw programmer wrote: Your suggestion didn't work
what part didn't work? did you get the callback from the load event?
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
I was trying to do this:
function MyClass
{
this.property1 = 'somevalue1';
this.property2 = 'somevalue2';
this.Height = 0;
this.Width = 0;
$('<img />').attr({'id': id, 'src' : src}).load(function()
{
if (true === this.complete)
{
Width = this.width;
Height = this.height;
}
});
}
That didn't work (this.width and this.height were the expected values, but trying to assign the vars did not work. So I changed it to this:
function MyClass
{
this.property1 = 'somevalue1';
this.property2 = 'somevalue2';
var Height = 0;
var Width = 0;
$('<img />').attr({'id': id, 'src' : src}).load(function()
{
if (true === this.complete)
{
Width = this.width;
Height = this.height;
}
});
this.width = function()
{
return Width;
}
this.height = function()
{
return Height;
}
}
I have no idea why I can't assign vars the way I originally tried it. IMHO, Javascript is nothing more than a hack whose main intent is to drive real programmers insane.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
John Simmons / outlaw programmer wrote: $('<img />').attr({'id': id, 'src' : src}).load(function()
{
if (true === this.complete)
{
Width = this.width;
Height = this.height;
}
});
did you account for the fact that the .load(...) is an asynchronous function?? the other thing of course is putting a break point in the response for the load function.
maybe you are getting a bad response from the load response because it's pathed out wrong??
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
My level of frustration with javascript is pretty freakin' high right now, and my opinion of the architecture is about as low as it can possibly get.
I can't seem to get a grasp of how things are scoped.
I'd really like to cuss like a sailor and kick the dog right about now.
the only thing that IS right is the path to the file.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
have you tried debugging with Chrome??
John Simmons / outlaw programmer wrote:
I can't seem to get a grasp of how things are scoped.
hahaha... it's the whole this concept mixed with callback functions isn't it? I liken the whole thing to pointers way back in the day of C/C++ eventually the light bulb turns on and it all makes perfect sense.
for things like this I use http://jsfiddle.net/[^] to play around an experiment. I prototyped the plugin that I wrote for http://dooscrib.com/[^] using jsfiddle.
hope it helps and if needed let me know.
as if the facebook, twitter and message boards weren't enough - blogged
|
|
|
|
|
Dennis E White wrote: have you tried debugging with Chrome??
Yes. That's what I'm using now.
Dennis E White wrote: hahaha... it's the whole this concept mixed with callback functions isn't it?
Well, sort of. I have something like the following:
var TOH = function(in_path, in_parentDiv, in_mouseOver)
{
var _array = new Array(),
_xmlFile = "",
_data1 = "",
init = function(path, parentDiv, mouseOver)
{
_xmlFile = path + "datafile.xml";
loadData();
},
loadData = function()
{
$.ajax
({
type: "GET"
,url: _xmlFile
,dataType: "xml"
,success: function(xml)
{
parseConfig ($(xml).find('Config'));
parseImages ($(xml).find('Images'));
}
,error: function(jqXHR, status, error)
{
alert(error);
}
});
},
parseConfig = function(nodelist)
{
_data1 = $(nodelist).find("Item1").text();
},
parseImages = function(nodeList)
{
if (nodeList != null)
{
$(nodeList).find('Image').each(function()
{
var count = _array.length;
_array[count] = new TreeImage(this, count, _data1, 0);
});
}
};
init(in_path, in_parentDiv, in_mouseOver);
};
In any case, I THOUGHT that the vars defined in TOH were going to be set by the functions that are also in TOH. That doesn't appear to be the case at all, and instead, the variables appear to be defined within the confines of each function, and once the function exits, the variables in TOH are unchanged from their original values. What's really puzzling is that when I call init , it properly sets the vars defined in TOH, so I'm sitting here pissed off because I don't understand why.
Another mystery is that despite having well over a dozen vars defined in TOH, only a few show up in the associated "Closures" panel in the debugger. Each var is initialized to a value when it's declared, so I don't understand why they don't show up.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
modified 26-May-13 9:27am.
|
|
|
|
|
|
I want the actual dimensions of the image, not of it's rendered size.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997
|
|
|
|
|
|