7

How to call a jquery function of a view in another view encoder

 2 years ago
source link: https://www.codesd.com/item/how-to-call-a-jquery-function-of-a-view-in-another-view-encoder.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

How to call a jquery function of a view in another view encoder

advertisements

I have a header view which is loaded in every view. I have a jquery function in header view and want to use that jquery function in another views jquery function.

Header view jquery function:

$('#myAccount').click( function() {
                loadPopupBox();
               $('.login_pop_right').fadeTo('slow',1);
                $("#mdhemadd").attr('disabled',false);
                $("#mdhpass").attr('disabled',false);
           });

I want to access it another views jquery function:

    $('#shortlist').click(function(){
    var userid = $('#userid').val();
    var dealid = $('#dealid').val();
    if(userid!=''){
        $.ajax({  

            type: "POST",
            url:  "/packagedetails/shortlistdeal",

            data: "userid=" +  userid+"&dealid="+dealid,

            //   data: form_data,
            success: function(data) {
                var obj = jQuery.parseJSON(data);
                if(obj==true)
                {
   loadShortlistPopupBox();
   $('#shortlistmsg').empty();
    var html='<span class="messageicon"></span><p>Deal shortlisted sucessfullly.</p>';
    $('#shortlistmsg').append(html);
                  //  alert("Deal shortlisted sucessfullly");
                }
                else
                {
  loadShortlistPopupBox();
  $('#shortlistmsg').empty();
    var html='<span class="messageicon"></span><p>This deal cannot be shortlisted.Please check your account for your <a href="/myaccount">shortlisted deals</a>.</p>';
    $('#shortlistmsg').append(html);
              //      alert("This deal cannot be shortlisted.Please check your account for your shortlisted deals.");
                }
            }
        });

    }
    else
    {
    alert("sd");
     $('#myAccount').click();
    }
});

How to do it?

Thanks,


Create one file with script.js, add this code in it. then include that in every page. so it works


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK