У меня есть функция jquery под названием MyFunc() в отдельном файле .js. Я хотел вызвать эту функцию в C# -коде за событием нажатия кнопки. (то есть, если данные будут добавлены успешно, вызовите MyFunc()
). Первоначально эта функция выглядела как этотВызов функции jquery из кода позади doesnt работает
$(".next").click(function() {
, где он будет непосредственно называться во время, когда жерех: кнопка нажата.
<asp:button id="btnNext" runat="server" CssClass="next action-button" Text="Next" OnClientClick="return false"/>
Так что я изменил функцию
function MyFunc(){}
и кнопку
<asp:Button ID="btnNext" runat="server" Text="Next" CssClass="action-button" OnClick="btnNext_Click1"/>
и в коде позади события нажатия кнопки
Page.ClientScript.RegisterClientScriptInclude(GetType(), "MyScript", "Easying.js");
Page.ClientScript.RegisterClientScriptInclude(GetType(), "MyScript", "Reg.js");
Page.ClientScript.RegisterStartupScript(GetType(), "MyScript", "MyFunc()", true);
это не дает мне никаких ошибок , Но это не работает. ниже - это функция.
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
$(".next").click(function() {
if (animating) return false;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({ opacity: 0 }, {
step: function (now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50) + "%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({ 'transform': 'scale(' + scale + ')' });
next_fs.css({ 'left': left, 'opacity': opacity });
},
duration: 800,
complete: function() {
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});
});
также, как вы можете видеть, MyFunc() используется для перехода от одного набора полей к другому. На моей странице aspx есть 3 поля. и индикатор выполнения (1--2-3). Индикатор выполнения должен перемещаться от одного к другому. и полевые изменения также изменяются. в текущей ситуации я вижу, что индикатор выполнения перемещается от 1 до непосредственно 3. и никаких изменений в наборе полей. вот где я взял код для этого. Как уже упоминалось выше, он отлично работает, когда я вызываю его непосредственно на странице aspx. http://codepen.io/atakan/pen/gqbIz
heres MyFunc() !!
function MyFunc() {
var current_fs, next_fs, previous_fs; //fieldsets
var left, opacity, scale; //fieldset properties which we will animate
var animating; //flag to prevent quick multi-click glitches
if (animating) return false;
animating = true;
current_fs = $(this).parent();
next_fs = $(this).parent().next();
//activate next step on progressbar using the index of next_fs
$("#progressbar li").eq($("fieldset").index(next_fs)).addClass("active");
//show the next fieldset
next_fs.show();
//hide the current fieldset with style
current_fs.animate({ opacity: 0 }, {
step: function (now, mx) {
//as the opacity of current_fs reduces to 0 - stored in "now"
//1. scale current_fs down to 80%
scale = 1 - (1 - now) * 0.2;
//2. bring next_fs from the right(50%)
left = (now * 50) + "%";
//3. increase opacity of next_fs to 1 as it moves in
opacity = 1 - now;
current_fs.css({ 'transform': 'scale(' + scale + ')' });
next_fs.css({ 'left': left, 'opacity': opacity });
},
duration: 800,
complete: function() {
current_fs.hide();
animating = false;
},
//this comes from the custom easing plugin
easing: 'easeInOutBack'
});};
Ум, чтобы опубликовать свое определение MyFunc()? – Hatjhie
$ (". Next"). Click (function(), это была функция, которую я изменил на MyFunc(), ее опубликовали выше !! –
У вас есть элемент с классом 'next'? Вы опускаете класс' next' на свой new 'button' – Kyojimaru