model view controller - Jquery chosen plugin works in one page but not in another one -


hi have used chosen in other projects before , havent had problems in current project can't work on specific page, although works on page.

firebug gives me error:  syntaxerror: expected expression, got '<'  '!doctype html'  chosen.jquery.js (row 1)   syntaxerror: expected expression, got '<'  '!doctype html'   prism.js (row 1)   typeerror: $(...).chosen not function  $(selector).chosen(config[selector]); 

the site develop using mvc framework , view display/loads script, 1 doesnt work, looks (edit-question):

<h1><?=$title?></h1>  <form method='post'>      <fieldset>          <input type='hidden' name='id' value='<?=$id?>' required/>          <input id='textfield' type='text' name='titel' placeholder='titel' value='<?=$titel?>' tabindex='1' required/>          <textarea id='askquestion' name='text' placeholder='fråga' tabindex='2' required/><?=$text?></textarea>          <select name='tags[]' data-placeholder='välj taggar, minst 1 - högst 5' class='chosen-select-deselect' tabindex='2'  multiple >              <option value=''></option>              <?php                  foreach($tags $tag){                  $selected="";                  foreach($selectedtags $selectedtag){                      if($tag->name == $selectedtag){                          $selected = "selected";                      }                  }                      echo "<option value='$tag->id' $selected >{$tag->name}</option>";                  }               ?>           </select>          <input class='newtags' type='text' name='newtags' placeholder='ange ny tagg/taggar "taggnamn, taggnamn"'/>      <input type='submit' name='editquestion' value='uppdatera'>      </fieldset>    <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js' type='text/javascript'></script>      <script src='js/chosen_v1.4.1/chosen.jquery.js' type='text/javascript'></script>      <script src='js/chosen_v1.4.1/docsupport/prism.js' type='text/javascript' charset='utf-8'></script>      <script type='text/javascript'>      var config = {        '.chosen-select'           : {},        '.chosen-select-deselect'  : {allow_single_deselect:true, width:'100%', max_selected_options:5},        '.chosen-select-no-single' : {disable_search_threshold:10},        '.chosen-select-no-results': {no_results_text:'oops, nothing found!'},        '.chosen-select-width'     : {width:'95%'}      }        (var selector in config) {        $(selector).chosen(config[selector]);      }      </script>  </form>

the view work (ask-question):

<h1><?=$title?></h1>  <form method='post'>      <fieldset>          <input id='textfield' type='text' name='titel' placeholder='titel' tabindex='1' title='ange en titel på frågan' required/>          <textarea id='askquestion' name='text' placeholder='fråga' tabindex='2' title='ange frågan' required/></textarea>          <select name='tags[]' data-placeholder='välj taggar, minst 1 - högst 5' class='chosen-select-deselect' tabindex='3' multiple >              <option value=''></option>              <?php foreach($tags $tag) : ?>                  <option value='<?=$tag->id?>'><?=$tag->name?></option>              <?php endforeach; ?>          </select>          <input class='newtags' type='text' name='newtags' placeholder='ange ny tagg/taggar "taggnamn, taggnamn"'/>      <input type='submit' name='createquestion' value='skapa'>      </fieldset>          <script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js' type='text/javascript'></script>      <script src='js/chosen_v1.4.1/chosen.jquery.js' type='text/javascript'></script>      <script src='js/chosen_v1.4.1/docsupport/prism.js' type='text/javascript' charset='utf-8'></script>      <script type='text/javascript'>      var config = {        '.chosen-select'           : {},        '.chosen-select-deselect'  : {allow_single_deselect:true, width:'100%', max_selected_options:5},        '.chosen-select-no-single' : {disable_search_threshold:10},        '.chosen-select-no-results': {no_results_text:'oops, nothing found!'},        '.chosen-select-width'     : {width:'95%'}      }      (var selector in config) {        $(selector).chosen(config[selector]);      }      </script>  </form>

both views, when displayed, have same file path , thing can think of differentiate 2 views/pages 1 doesnt work(edit-question) have different url, webroot/questions/edit-question/3/3/8, while other one, ask-question, have webroot/ask-question. furthermore, edit-question populateing html input elements values.

i'am not versed jquery/javascript appriciated!

/ph


Comments

Popular posts from this blog

google chrome - Developer tools - How to inspect the elements which are added momentarily (by JQuery)? -

angularjs - Showing an empty as first option in select tag -

php - Cloud9 cloud IDE and CakePHP -