Frage

this is html code in webuser control

    <telerik:RadMultiPage ID="RadMultiPage1" runat="server" SelectedIndex="0" Width="100%">
        <telerik:RadPageView ID="RadPageView1" runat="server">

        <link rel="stylesheet" href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" />
        <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
        <script src="http://code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
        <script type="text/javascript">
            $(function (){
            $('#btn_jquerycall').button().click(function () {
                alert("Comming Soon!");
            });
        });
    </script>
        <fieldset>
            <div style="margin-top: 10px; margin-left: 10px;">
                <span style="font-weight: bold;">
                    <asp:Literal runat="server" ID="lblSubject" />
                </span><span style="font-style: italic;">
                    <asp:Literal runat="server" ID="lblDate" Text=" - {0:dd/MM/yyyy}" />
                </span>
            </div>
            <div class="event">
                <asp:Literal runat="server" ID="lblContent" />
            </div>
        </fieldset>
        <div>
            <telerik:RadButton ID="telerik_button" runat="server" Text="Telerik Button" 
                    Height="35">
                    <Icon PrimaryIconUrl="~/Images/iconGreen.png" PrimaryIconWidth="32" PrimaryIconHeight="32"
                        PrimaryIconCssClass="PrimaryIcon" />
                </telerik:RadButton>
                <input id="btn_jquerycall" type="button" value="Alert Jquery"/>
        </div>
    </telerik:RadPageView>
</telerik:RadMultiPage>

the problem is that when the first time i load this page, Jquery work well when i click on btn_jquerycall button that means alert were called. But when i click on telerik_button this webuser control was loaded and in the second time loading when i click on btn_jquerycall again, jquery didn't called as well as i tried to move btn_jquerycall outside of RadMultipage..

How do i can work with jquery in the second time loading? Need help.....

War es hilfreich?

Lösung

Try this:

The Script code should be in RadCodeBlock tag outside the RadMultiPage, like this :

<telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
<script type="text/javascript">
    $(document).ready(function (){
        $("#<%=btn_jquerycall.Client%>").click(function () {
            alert("Comming Soon!");
        });
    });
 </script>
</telerik:RadCodeBlock>

RadcodeBlock

Andere Tipps

You should write it like this.

$(function (){
    $('#btn_jquerycall').click(function () {
        alert("Comming Soon!");
    });
});

or you may use it this way

$(document).ready(function (){
    $('#btn_jquerycall').click(function () {
        alert("Comming Soon!");
    });
});

Try to put into your script tag following function:

$(document).ready(function(){
   var $button = $('#btn_jquerycall');
    $button.button();
   if(typeof $button === undefined)
       alert('Button not founded');
   else
       $button.on('click', function(){
           alert('Comming soon');
       });
});

If after page load it gives 'Button not founded' alert it means your page not loaded correctly. If it does exist in your page it will should work.

Edit:

Try following link.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top