Reputation: 2667
I have a click
function in jQuery and it never seems to execute. I need another pair of eyes:
The ASP button:
<asp:Button ID="btnSubmit" runat="server" Text="Transfer" CssClass="btnSubmit" Enabled="false" />
The Javascript/jQuery
$(".btnSubmit").click(function () {
var count = ticks.length;
var x;
for (var i = 0; i < count; i++) {
if (ticks[i].Symbol == pair) {
x = $(".txtAmount").val() * ticks[i].Ask;
if (x != null || x != 0) {
$(".txtResult").val() = "=" + x;
}
}
}
});
Upvotes: 0
Views: 298
Reputation: 2667
Seems as if there is an issue with Umbraco if someone could clarify why this might be I would be greatful.
For now my solution involved doing the following:
Replacing <asp:Button ID="MyButton" Text="Transfer"></asp:Button>
with <input type="submit" value="Transfer" onclick="calculate()" />
Using simple javascript event over the the jquery event. I can get the jquery to work outside of umbraco.
I replaced asp:Button because I do not need a postback on click, and the input field can do the same job for me.
Upvotes: 0
Reputation: 550
Is your "txtResult" element a textbox? You cannot assign a value to a textbox like you are here:
$(".txtResult").val() = "=" + x;
You would need to do this:
$(".txtResult")[0].value = "=" + x;
Small example: http://jsfiddle.net/wqZmv/
Otherwise I would need to see more of the code if it is a different issue.
Upvotes: 1
Reputation: 4924
Step 1: replace your click function with:
$('.btnSubmit').click(function(){
alert('works');
});
If you get an alert, there is something wrong with all that internal code. Can't help you much there since it has a bunch of variable and class names you haven't showed us.
If it doesn't work... maybe issues including jQuery properly?
Anyway, those are just the steps of debugging. Simplify your code to rule out portions/lines and add back in functionality until it breaks. The last thing you added is what is broken.
Upvotes: 1
Reputation: 1523
Try this:
$("#btnSubmit").click(function () {
var count = ticks.length;
var x;
for (var i = 0; i < count; i++) {
if (ticks[i].Symbol == pair) {
x = $(".txtAmount").val() * ticks[i].Ask;
if (x != null || x != 0) {
$(".txtResult").val() = "=" + x;
}
}
}
});
Upvotes: -1