Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7023245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:41:12+00:00 2026-05-27T23:41:12+00:00

I was not sure the best way to go about this. Basically, I have

  • 0

I was not sure the best way to go about this.

Basically, I have a partial view that may be put on a page multiple times, and in the partial view, it contains jQuery which binds to certain events for things that may happen on the page. For example, button clicks etc.

Now, using jQuery selectors, you would target things on the page using an ID (which I cant do as then multiple things on the page would have the same ID). You could also use class names to be able to select things, but this wont work either, as for each partial view they will all target each other, which cannot happen.

I need each piece of jQuery to only select things from its own partial view. How would I do this?

I can only think of one way to do it, and it seems a bit of a hack. But I could basically create a model, that contains a string, which would be a selector for the container that will surround the partial view. Then in the view it would use the selector as well as the normal classs names it would normall use.

Is there a better way?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:41:13+00:00Added an answer on May 27, 2026 at 11:41 pm

    I would make sure your partial view’s content is contained in some sort of uniquely marked div (whether it be id or class or whatever). Limit the scope to that id.

    I suppose I would define the Id as, perhaps, var myId = Guid.NewGuid().ToString("N"); at the top of the partial and make sure the partials content content is wrapped in something like <div id="@myId"> …and then in your jquery make your selector limit the scope to @myId

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not sure the best way to go about this, basically I have
Im not sure about the best way to do this but I have a
I am not sure if I am going about this the best way, but
So I'm not sure what the best way to accomplish this is, but basically
i am not sure the best way to go about this. here is the
I'm new to MVC (MVC3) so not sure about the best way to implement
I'm not quite sure the best way to deal with this situation. Here's a
I'm not sure if this is the best way to do it, but I
I'm not entirely sure if this is the best way to word it, however,
I've got a design idea that I'm not exactly sure the best way to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.