Note that there are some explanatory texts on larger screens.

plurals
  1. POWorking with hashtags
    text
    copied!<p>Lets think that our URL look like</p> <p>www.domain.com <strong>#CourseID#LessonID</strong></p> <p>What I'm trying to do is, when:</p> <ul> <li><code>CourseDivButton</code> clicked if current url <ul> <li>Has no hashtag (www.domain.com) then just add <code>$(this).data("id")</code> as hashtag (www.domain.com <strong>#CourseID</strong>)</li> <li>Contains only first hashtag - <code>CourseID</code> (www.domain.com <strong>#CourseID</strong>) then change it (www.domain.com <strong>#NEWCourseID</strong>)</li> <li>Contains 2 hashtags - <code>CourseID</code> and <code>LessonID</code> (www.domain.com <strong>#CourseID#LessonID</strong>) then delete second and change first (www.domain.com <strong>#NEWCourseID</strong>)</li> </ul></li> <li><code>LessonDivButton</code> clicked if current url <ul> <li>Contains only first hashtag - <code>CourseID</code> (www.domain.com <strong>#CourseID</strong>) then add second (www.domain.com <strong>#CourseID#LessonID</strong>)</li> <li>Contains 2 hashtags - <code>CourseID</code> and <code>LessonID</code> (www.domain.com <strong>#CourseID#LessonID</strong>) then change second and leave first as it is (www.domain.com <strong>#CourseID#NEWLessonID</strong>)</li> </ul></li> </ul> <p>My code now looks like below. Can't figure out how to achieve what I want.</p> <pre><code>CourseDivButton.click(function(){ var id=$(this).data("id"); LoadLessons(id); window.location.hash = id; }); LessonDivButton.live("click", function(){ var id=$(this).data("id"); LoadQuestions(id); window.location.hash = id; }); </code></pre> <p>Any suggestions?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload